我有一个叫做轨道返回的数据帧,我从一个csv中提取出来:
orbitalreturns = pd.DataFrame.from_csv('Orbital returns.csv',index_col=0,header=0)
2014-02-28 NaN
2014-03-31 1.17%
2014-04-30 1.01%
2014-05-31 2.77%
2014-06-30 2.41%
2014-07-31 -5.44%
我只想画出来,但得到:
TypeError: Empty 'DataFrame': no numeric data to plot
我试过:
orbitalreturns['OrbitalReturns'].strip('%')
但是得到:
AttributeError: 'Series' object has no attribute 'strip'
删除%符号并转换为浮点数:
要处理字符串,需要使用如下所述的.str方法:https://pandas.pydata.org/pandas-docs/stable/text.html#indexing-with-str
此代码应该可以工作(错误将导致NaN值-感谢您的评论):
打印时:
你得到(看起来很好):
检查下面每个系列中的值:
相关问题 更多 >
编程相关推荐