Python pandas plot time-series with gap

前端 未结 2 2019
春和景丽
春和景丽 2021-01-02 20:58

I am trying to plot a pandas DataFrame with TimeStamp indizes that has a time gap in its indizes. Using pandas.plot() results in linear interpolation between the last TimeSt

2条回答
  •  天涯浪人
    2021-01-02 21:37

    In my case I had DateTimeIndex objects instead of TimeStamp, but the following works for me in pandas 0.24.2 to eliminate the time series gaps after converting the DatetimeIndex objects to string.

    df = pd.read_sql_query(sql, sql_engine)
    df.set_index('date'), inplace=True)
    df.index = df.index.map(str)
    

提交回复
热议问题