[Python] pandas timeseries line plot not matching up python

Discussão em 'Python' iniciado por Stack, Setembro 26, 2024.

  1. Stack

    Stack Membro Participativo

    I am having issues where I have 2 pandas dataframe timeseries. One is in US/central time (realized_production) and the other is in UTC (hindcast_2022). I am trying to plot monthly time series plots to compare both time series. However, no matter how I shift the data and play with the timezone settings, these time series still look offset. Can someone tell me what I am doing wrong?

    #Dataframe 1: Before time column converted to datetime


    [​IMG]

    #After column converted to datetime and subset the dataframe to 2022 data only
    scaled_pwrts['Timestamp'] = pd.to_datetime(scaled_pwrts['Timestamp'],utc=True)
    hindcast_2022=scaled_pwrts["01-01-2022":"12-31-2022"]


    [​IMG][​IMG]

    #Dataframe 2: before column converted to datetime


    [​IMG]

    #After conversion to datetime
    realized_production["DELIVERY_START"] = pd.to_datetime(realized_production["DELIVERY_START"],utc=True)


    '''[​IMG]

    #Loop over every month and plot the line timeseries for "hindcast_2022" and "realized_production" dataframes.
    fig = plt.figure(figsize=(40, 30))

    for i in np.arange(1,13):
    hindcast_2022_i = (hindcast_2022["Gross Power"])[hindcast_2022.Timestamp.dt.month==i]
    actual_2022_i = realized_production["DERMOTT"] [realized_production.DELIVERY_START.dt.month==i]
    ax= plt.subplot(6,2,i)
    (hindcast_2022_i/1000).plot(ax=ax,label="hindcast")
    actual_2022_i.plot(ax=ax,label="actual")
    ax.set_title("Month= "+str(i))
    ax.legend()


    [​IMG]

    Continue reading...

Compartilhe esta Página