Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check for any missing dates in the index

Tags:

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.

like image 307
user_6396 Avatar asked Aug 27 '18 17:08

user_6396


People also ask

How does Python handle missing dates?

To add missing dates to Python Pandas DataFrame, we can use the DatetimeIndex instance's reindex method. We create a date range index with idx = pd. date_range('09-01-2020', '09-30-2020') .

How do you check for missing values in pandas?

In order to check missing values in Pandas DataFrame, we use a function isnull() and notnull(). Both function help in checking whether a value is NaN or not. These function can also be used in Pandas Series in order to find null values in a series.


1 Answers

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

like image 88
Vaishali Avatar answered Sep 30 '22 04:09

Vaishali