python 数组转dataframe
时间: 2023-10-15 12:25:16 浏览: 109
用Python玩转数据 04_4-dataframe.mp4
在Python中,将数组转换为DataFrame可以使用`pd.DataFrame()`函数进行转换。具体实例如下:
```python
import pandas as pd
# 定义数组
data = {'name':['Zhang San','Li Si','Wang Wu'], 'salary':['5000','7000','10000']}
array = pd.DataFrame(data)
# 将数组转换为DataFrame
df = pd.DataFrame(array)
# 打印DataFrame
print(df)
```
以上代码将数组转换为DataFrame并打印出来。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [python中Array和DataFrame如何相互转换](https://blog.csdn.net/ChenADC/article/details/122139684)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *3* [Python实现把多维数组展开成DataFrame](https://download.csdn.net/download/weixin_38670391/14009137)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文