【发布时间】:2021-09-24 03:31:15
【问题描述】:
我正在编写此代码来转换特定 csv 文件中的列,然后将其转换为人类可读的时间。但是,只有当我指定一个数据值并且当我尝试转换整个列时它才会显示此错误:
TypeError:无法将系列转换为
import pandas as pd
from tkinter.filedialog import askopenfilename
import csv
from datetime import datetime, timedelta
n=0
file_path= askopenfilename(filetypes=(("CSV File","*.csv"),("All files","*.*")))
print(file_path)
selected_File = pd.read_csv(file_path)
print(selected_File.iloc[:,0])
dtime=datetime.fromtimestamp(selected_File.iloc[:,0])
print(type(dtime))
initial_date="1/1/1900 0:00:00"
i_date= datetime.strptime(initial_date,"%m/%d/%Y %H:%M:%S")
correct_date=i_date+timedelta(days=selected_File.iloc[:,0])
print(correct_date)
【问题讨论】:
标签: python pandas csv error-handling time-series