dataframe存成npy
时间: 2023-11-18 20:54:29 浏览: 421
你可以使用下面的代码将DataFrame存储为.npy文件:
```python
import pandas as pd
import numpy as np
# 读取DataFrame数据
df = pd.read_csv("your_data.csv")
# 将DataFrame转换为numpy array
data = np.array(df)
# 保存为.npy文件
np.save("your_data.npy", data)
```
请确保将"your_data.csv"替换为你的实际数据文件名,"your_data.npy"替换为你想要保存.npy文件的名称。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [python将DataFrame或者npy数据保存到指定的文件夹(非默认目录)](https://blog.csdn.net/HYQ666888999/article/details/112853262)[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_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [9.Python办公自动化,pandas,numpy数据转换成DataFrame数据](https://blog.csdn.net/weixin_42605384/article/details/116812107)[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_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文