【发布时间】:2021-09-29 08:32:30
【问题描述】:
我有一个数据数组 10000*3 需要保存为 csv 文件。下面是我的伪代码,但我不知道如何仅使用 numpy(不是 pandas)来实现它。有人知道该怎么做?
import numpy as np
import time
arr = np.random.randn(10000, 3)
# That need arr[0,0] = time.time(), arr[i, 0] = time.time() + i
arr[:,0] = time.time() + 1
# And after that, I need to column 1 to datatime string(like "2021-02-12 12:12:12")
arr[:,0] need to apply `time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(item))` this function.
# After that, the data type is, column1:str, column2:float, column3:float and to save it as a csv file.
【问题讨论】:
标签: python-3.x numpy