Python pandas as soon as build a DataFrame that actually has a datapoint and leave a space

I have a DataFrame with intraday data indexed using DatetimeIndex

df1 =pd.DataFrame(np.random.randn(6,4),index=pd.date_range('1/1/2000',periods=6, freq='1h'))
df2 =pd.DataFrame(np.random.randn(6,4),index=pd.date_range('1/2/2000',periods=6, freq='1h'))
df3 = df1.append(df2)

as you can see that for two days there is a big gap in df3

df3.plot ()

will be every hour from 2000-01-01 00:00:00to 2000-01-02 05:00:00, but in fact from 2000-01-01 06:00:00to 2000-01-02 00:00:00there is actually no datapoint.

How to leave this data point on the chart so that from 2000-01-01 06:00:00to is 2000-01-02 00:00:00not displayed?

+5
source share
2 answers

It seems like this has been around Google Groups for some time.

Pandas Counts Intraday Time Series

+2
source

- resample () , :

df3.resample('H').plot()

. , NaN , ( ). , , .

+2

All Articles