时间序列画图 pandas Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'

这是我的数据

图片说明

数据类型为


JD         datetime64[ns]
Mage               object
Magnorm            object
dtype: object

想以时间为x轴的图

down_timedf = target_star_df['Magnorm'].resample('3T').mean()

down_timedf.plot()

plt.legend(bbox_to_anchor=(1.25, 0.5))
plt.title('time_Magnorm')
sns.despine()


出现

TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'

错误

TypeError                                 Traceback (most recent call last)
<ipython-input-138-8281def7eb17> in <module>()
      1 
----> 2 down_timedf = target_star_df['Magnorm'].resample('3T').mean()
      3 
      4 down_timedf.plot()
      5 # 图示的说明

/opt/conda/lib/python3.6/site-packages/pandas/core/generic.py in resample(self, rule, how, axis, fill_method, closed, label, convention, kind, loffset, limit, base, on, level)
   5520                      axis=axis, kind=kind, loffset=loffset,
   5521                      convention=convention,
-> 5522                      base=base, key=on, level=level)
   5523         return _maybe_process_deprecations(r,
   5524                                            how=how,

/opt/conda/lib/python3.6/site-packages/pandas/core/resample.py in resample(obj, kind, **kwds)
    997     """ create a TimeGrouper and return our resampler """
    998     tg = TimeGrouper(**kwds)
--> 999     return tg._get_resampler(obj, kind=kind)
   1000 
   1001 

/opt/conda/lib/python3.6/site-packages/pandas/core/resample.py in _get_resampler(self, obj, kind)
   1114         raise TypeError("Only valid with DatetimeIndex, "
   1115                         "TimedeltaIndex or PeriodIndex, "
-> 1116                         "but got an instance of %r" % type(ax).__name__)
   1117 
   1118     def _get_grouper(self, obj, validate=True):

TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'

请问各位大佬 这是什么问题呢
如何修改呢

https://blog.csdn.net/weixin_38168620/article/details/79596564?utm_source=blogxgwz2