Pandas and Matplotlib - fill_between() vs datetime64

后端 未结 4 1324
旧巷少年郎
旧巷少年郎 2020-11-29 07:15

There is a Pandas DataFrame:


Int64Index: 300 entries, 5220 to 5519
Data columns (total 3 columns):
Date                 


        
4条回答
  •  借酒劲吻你
    2020-11-29 07:50

    I encountered this issue after upgrading to Pandas 0.21. My code ran fine previously with fill_between() but broke after the upgrade.

    It turns out that this fix mentioned in @unutbu 's answer, which is what I had before anyway, only works if the DatetimeIndex contains date objects rather than datetime objects that has time info.

    Looking at the example above, what I did to fix it was to add the following line before calling fill_between():

    d['Date'] = [z.date() for z in d['Date']]
    

提交回复
热议问题