Workaround for Pandas FutureWarning when sorting a DateTimeIndex

后端 未结 1 1206
孤街浪徒
孤街浪徒 2021-01-13 18:44

As described here, Pandas.sort_index() sometimes emits a FutureWarning when doing a sort on a DateTimeIndex. That question isn\'t actionable, since it contains no MCVE. He

1条回答
  •  被撕碎了的回忆
    2021-01-13 19:10

    Issue confirmed for the 0.24.2 milestone. Workaround is to filter the warning, thus:

    with warnings.catch_warnings():
        # Pandas 0.24.1 emits useless warning when sorting tz-aware index
        warnings.simplefilter("ignore")
        ds = df.sort_index()
    

    0 讨论(0)
提交回复
热议问题