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.
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') .
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With