Jay Miloy
Jay Miloy

Reputation: 23

MatplotLib not properly plotting pandas timeseries 1 minute data after converting index to datetime object

I am having trouble plotting the timeseries 1 minute data after converting the index into a datetime object.

here is a chart before converting the index into a datetime object.

VIX 1 minute data chart

and this is the plotted chart after changing the index to a datetime object using df.index = pd.to_datetime(df.index)

VIX 1 minute data chart with problems

I am not sure what is happening here, but it looks like Matplotlib is missing certain values when i am converting into a 1 minute datetime object.

Here is a sample of the data https://easyupload.io/koh8s6

would appreciate if anyone can help out.

Upvotes: 0

Views: 147

Answers (1)

mozway
mozway

Reputation: 260300

It seems to work fine for me. Have you made sure to use a datetime type for your time index?

df = pd.read_csv('vixdatasample_to_SO.csv', index_col=[1])
df.index = pd.to_datetime(df.index)
df.iloc[:, 2:6].plot()
                     Unnamed: 0  Unnamed: 0.1   Open  Close   High    Low  Volume  ma  std  upper_band  lower_band
Time                                                                                                              
2021-01-19 08:15:00           0             0  23.03  23.01  23.03  23.01     0.0 NaN  NaN         NaN         NaN
2021-01-19 08:16:00           1             1  23.03  23.03  23.05  23.01     0.0 NaN  NaN         NaN         NaN
2021-01-19 08:17:00           2             2  23.04  23.04  23.06  23.04     0.0 NaN  NaN         NaN         NaN
2021-01-19 08:18:00           3             3  23.03  23.03  23.03  23.03     0.0 NaN  NaN         NaN         NaN
2021-01-19 08:19:00           4             4  23.05  23.06  23.06  23.05     0.0 NaN  NaN         NaN         NaN

enter image description here

Upvotes: 1

Related Questions