Plot pandas dataframe containing NaNs

后端 未结 4 566
星月不相逢
星月不相逢 2020-12-09 16:23

I have GPS data of ice speed from three different GPS receivers. The data are in a pandas dataframe with an index of julian day (incremental from the start of 2009).

4条回答
  •  无人及你
    2020-12-09 17:25

    I found even if the df was indexed as DateTime the same issues occurred. One solution to ensure all data points are respected, with no gaps in between lines, is to plot each df column separately and dropping the NaNs.

        for col in df.columns:
            plot_data = df[col].dropna()
            ax.plot(plot_data.index.values, plot_data.values, label=col)
    

提交回复
热议问题