我试图将开始时间转换为 int,将其添加到数据框中,然后绘制散点图。
test_df['Start'] = test_df['start'].astype(np.int64)
icma_df.plot.scatter(x='Start', y='marks').convert_objects(convert_numeric=True)
上面的代码给出了以下错误。
ValueError: invalid literal for int() with base 10: '29 Jan 2016 06:56'
最佳答案
'29 Jan 2016 06:56'
不是 pandas/numpy 日期时间,而是字符串。首先使用 pd.to_datetime
将 'start'
转换为日期时间。
关于python - 在 Pandas 中将日期时间转换为 int 时出现 ValueError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40753055/