-1

I'm trying to plot a Pandas Series with lots of samples:

In [1]: vp_series = pd.Series(data=raw_df.Count, index=raw_df.Timestamp)

In [2]: len(vp_series)
Out[2]: 17499650

In [3]: vp_series.index[-1]
Out[3]: 559888625359

When I try to plot this series, the produced plot looks like this:

In [4]: vp_series.plot()

enter image description here

Clearly not all data points are plotted, and max value on the x axis is only about 1.75e7 instead of 5.59e11.

However, when I try to plot the same data in Julia (using Plots and the PyPlot backend) it produces the correct figure:

enter image description here

What should I do here to make the plot contain all the data points? I tried to search in the doc of matplotlib and Pandas.Series but found nothing.

B. Wang
  • 31
  • 5
  • 1
    I suggest you provide a [Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). It might be clear for you that data points are missing. But we only see what you post here - and for me it is just a dataset that has irregular spacing. – Mr. T Jul 02 '18 at 23:58
  • Maybe this can help? https://stackoverflow.com/questions/47355526/pandas-series-not-plotting-to-timeseries-chart – rafaelc Jul 03 '18 at 02:01

1 Answers1

0

I found the reason is that the way I used to create the pandas.Series is wrong. Instead of

vp_series = pd.Series(data=raw_df.Count, index=raw_df.Timestamp)

I should be using

vp_series = pd.Series(data=raw_df.Count.values, index=raw_df.Timestamp)

The first way is causing my series to contain a lot of missing values (NaN) which are not plotted. The reason is well explained in here.

I know I didn't ask my question properly and I appreciate all the comments.

B. Wang
  • 31
  • 5