pythonpandasmissing-datapython-datetime

check for any missing dates in the index


Is there any way to check for missing dates in a dataframe directly. I want to check if there are a missing dates between 2013-01-19 to 2018-01-29

            GWA_BTC      GWA_ETH    GWA_LTC  GWA_XLM  GWA_XRP
   Date                 
2013-01-19  11,826.36   1,068.45    195.00    0.51    1.82
2013-01-20  13,062.68   1,158.71    207.58    0.52    1.75
   ...
2018-01-28  12,326.23   1,108.90    197.36    0.48    1.55
2018-01-29  11,397.52   1,038.21    184.92    0.47    1.43

I tried to check it manually but it took a lot of time.


Solution

  • You can use DatetimeIndex.difference(other)

    pd.date_range(start = '2013-01-19', end = '2018-01-29' ).difference(df.index)
    

    It returns the elements not present in the other