[Python] Pandas resample.plot() not working because DatetimeIndexResampler

Discussão em 'Python' iniciado por Stack, Maio 21, 2025.

  1. Stack

    Stack Membro Participativo

    I try to learn to use pandas, so I follow a tutorial. However, during the tutorial, there is this:

    bitcoin.loc['2019','Close'].resample('M').plot() plt.show()


    And it returns an error :

    AttributeError: 'DatetimeIndexResampler' object has no attribute 'plot'


    But the man in the video gets a graph with different colors split by month, I don't understand why? Maybe a wrong version of pandas or something else?

    The link to the tutorial video: https://youtu.be/qHRLG5hsW9I?t=353

    Try this:

    import numpy as np
    import matplotlib.pyplot as plt
    import pandas as pd

    bitcoin = pd.read_csv('BTC-EUR.csv',index_col='Date',parse_dates=True)

    bitcoin.loc['2019','Close'].resample('M').plot()
    plt.show()


    Download the dataset: BTC-EUR.csv = https://fr.finance.yahoo.com/quote/BTC-EUR/history?p=BTC-EUR

    Expected this:

    [​IMG]

    Got this:

    AttributeError: 'DatetimeIndexResampler' object has no attribute 'plot'

    Continue reading...

Compartilhe esta Página