Q:

Python Pandas: Making date index continuous

I have the following time series data:
           EventCount
Date
2015-06-23          1    
2015-06-25          1
2015-05-29          1

I need to pad the data, so the index has continuous dates, like this:
           EventCount
Date
2015-06-23          1
2015-06-24          0
2015-06-25          1
2015-06-26          0
2015-06-27          0
2015-06-28          0
2015-05-29          1

How could I do this?

A:

You can use the .reindex().
# your data
# ===================================
print(df)

            EventCount
Date                  
2015-06-23           1
2015-06-25           1
2015-06-29           1

# processing
# ==============================
df.reindex(pd.date_range(df.index[0], df.index[-1], freq='D')).fillna(0)

            EventCount
2015-06-23           1
2015-06-24           0
2015-06-25           1
2015-06-26           0
2015-06-27           0
2015-06-28           0
2015-06-29           1

