[Python] Can't make candle chart due to some error with mpf.plot

Discussão em 'Python' iniciado por Stack, Julho 19, 2025.

  1. Stack

    Stack Membro Participativo

    import pandas as pd

    import yfinance as yf
    import mplfinance as mpf
    df = yf.download('AMZN',start='2020-01-01',end='2025-07-31')
    print(df)
    mpf.plot(df['2020-01-01':'2020-06-01'], type='candle', volume=True)


    This is the code I have written.

    This is the output:

    Price Close High Low Open Volume
    Ticker AMZN AMZN AMZN AMZN AMZN
    Date
    2020-01-02 94.900497 94.900497 93.207497 93.750000 80580000
    2020-01-03 93.748497 94.309998 93.224998 93.224998 75288000
    2020-01-06 95.143997 95.184502 93.000000 93.000000 81236000
    2020-01-07 95.343002 95.694504 94.601997 95.224998 80898000
    2020-01-08 94.598503 95.550003 94.321999 94.902000 70160000
    ... ... ... ... ... ...
    2025-07-14 225.690002 226.660004 224.240005 225.070007 35702600
    2025-07-15 226.350006 227.270004 225.460007 226.199997 34907300
    2025-07-16 223.190002 226.100006 222.179993 225.880005 39535900
    2025-07-17 223.880005 224.500000 222.509995 223.320007 31855800
    2025-07-18 226.130005 226.399994 222.979996 225.139999 37811600

    [1393 rows x 5 columns]


    This is the error:

    mpf.plot(df['2020-01-01':'2020-06-01'], type='candle', volume=True)
    ~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    dates,opens,highs,lows,closes,volumes = _check_and_prepare_data(data, config)
    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
    raise ValueError('Column "'+col+'" NOT FOUND in Input DataFrame!'+
    '\n CHECK that your column names are correct AND/OR'+
    '\n CHECK for leading or trailing blanks in your column names.')
    ValueError: Column "Open" NOT FOUND in Input DataFrame!
    CHECK that your column names are correct AND/OR


    I tried to make candle stick chart using mplfinance but I could not. It seems that there is some error with the way I use the plot() function but I tried checking the syntax and as per my observations, it is correct.

    Continue reading...

Compartilhe esta Página