[英]How to save Pandas dataframe into a npz file?
I have some dataframes which are loaded from different npz
files.我有一些数据帧是从不同
npz
文件加载的。 I combine all the data into a single dataframe and apply some processing to it.我将所有数据组合成一个 dataframe 并对其进行一些处理。 Now I want to save the new combined dataframe into a new
npz
file.现在我想将新组合的 dataframe 保存到一个新的
npz
文件中。 How do I do that?我怎么做?
Since the dataframe is large (5000 rows, 30 columns) I would also like to know the most efficient way of doing so.由于 dataframe 很大(5000 行,30 列),我也想知道最有效的方法。
I tried to look over the inte.net for the solution but the results are about how to convert pandas
dataframe to numpy
data.我试图查看 inte.net 的解决方案,但结果是关于如何将
pandas
dataframe 数据转换为numpy
数据。
It seems that the best solution for your problem is to convert your dataframe to a numpy array and afterwards save it.似乎解决您问题的最佳方法是将 dataframe 转换为 numpy 数组,然后保存。
np.savez(file, df.to_numpy())
file
has to be a file, in which you want to save your data and df
is the dataframe in which you have your data. file
必须是一个文件,您要在其中保存数据,而df
是您拥有数据的 dataframe。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.