Pandas and Matplotlib - fill_between() vs datetime64

后端 未结 4 1323
旧巷少年郎
旧巷少年郎 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:53

    I had a similar problem. I have a DataFrame that looks something like this:

    date        upper     lower 
    2018-10-10  0.999614  0.146746
    2018-10-26  0.999783  0.333178
    2019-01-02  0.961252  0.176736
    2019-01-08  0.977487  0.371374
    2019-01-09  0.923230  0.286423
    2019-01-10  0.880961  0.294823
    2019-01-11  0.846933  0.303679
    2019-01-14  0.846933  0.303679
    2019-01-15  0.800336  0.269864
    2019-01-16  0.706114  0.238787
    

    with dtypes:

    date     datetime64[ns]
    upper           float64
    lower           float64
    

    The following results in the error from the initial post

    plt.fill_between(dplot.date, dplot.lower, dplot.upper, alpha=.2)
    

    Interestingly,

    plt.fill_between(dplot.date.values, dplot.lower, dplot.upper, alpha=.2)
    

    works perfectly fine.

提交回复
热议问题