[英]retrieving data from a numpy array and storing in a dataframe
I currently have a .npy file and I would like to store the data it contains in a variable in order to convert it to a dataframe. 我目前有一个.npy文件,我想将其包含的数据存储在变量中,以便将其转换为数据框。
I tried using the following: 我尝试使用以下内容:
data_array=np.load('Jason1Data_Full_East_West.npy')
df = pd.DataFrame(data_array)
However my dataframe came out as a single column. 但是,我的数据框是单列显示的。 How do I save the data in a format where the columns are clearly separated with now square brackets around the rows?
如何将数据保存为一种格式,即各列之间用方括号括起来清晰地分开?
Even your question is not clear. 甚至您的问题也不清楚。 You can try the following:
您可以尝试以下方法:
path = .../Jason1Data_Full_East_West.npy
data = np.load(path)
And then you need to convert it to dataframe as the following: 然后需要将其转换为数据框,如下所示:
pd.DataFrame({'Data':data.tolist()})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.