简体   繁体   English

Python自动将数字转换为日期

[英]Python automatically converts number to date

I am dropping some numerical values in a column using the following code, but then it somehow changes all the numerical values to date type, which is not what I need. 我使用以下代码在列中删除了一些数值,但随后它以某种方式将所有数值更改为日期类型,这不是我所需要的。 I cannot see how to fix it, so I would really appreciate if some of you could help fix this error for me. 我看不到如何解决此问题,因此如果您中的某些人能帮助我解决此错误,我将不胜感激。

df = pd.read_csv(datapath+"CompleteOrder_HANOI_Alltime.csv") 
df = df.drop(df[df.completed_orders == 0].index)
df = df.dropna(subset = ["completed_orders"])
df['y'] = np.log(df['completed_orders'])

df['y'] = df.drop(df[df.y <= 0].index)
df = df.drop('completed_orders', axis = 1)
df = df.drop('percent_completed', axis = 1)
df['ds'] = df['to_char']
df = df.drop('to_char', axis = 1)
df['ds'] = pd.to_datetime(df['ds'])

Your last statement converts df['ds'] to datetime. 您的最后一条语句将df ['ds']转换为日期时间。 Add a print statement of df['ds'] to see what's being converted. 添加df ['ds']的打印语句以查看正在转换的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM