python - 检查索引中是否有任何缺失的日期

标签 python pandas missing-data python-datetime

有什么方法可以直接检查数据框中缺少的日期。 我想检查 2013-01-192018-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

我尝试手动检查,但花了很多时间。

最佳答案

您可以使用 DatetimeIndex.difference(other)

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

它返回另一个中不存在的元素

关于python - 检查索引中是否有任何缺失的日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52044348/

相关文章:

C#相当于Python的traceback库

r - 在数据框中输入附加行作为相邻现有行值之间的中点

python - Keras LSTM 未训练

python - 为什么单独附加一个列表会创建一个无限列表

python - 在索引上连接键列

Python pandas dataframe 将元素添加到前一行值并创建一个新列

python - 如何将值设置为 pandas DataFrame 的一列?

python - 在 Python 中按列顺序将特定列转换为行并保持其余列相同

python - 具有缺失数据的 boolean 系列的 pandas.eval

sas - SAS 如何区分缺失值和非缺失值?