How to get the closest single row after a specific datetime index using Python Pandas

后端 未结 3 447
温柔的废话
温柔的废话 2020-12-15 06:56

DataFrame I have:

            A   B   C 
2012-01-01  1   2   3 
2012-01-05  4   5   6 
2012-01-10  7   8   9 
2012-01-15  10  11  12 

What

3条回答
  •  伪装坚强ぢ
    2020-12-15 07:38

    Couldn't resist answering this, even though the question was asked, and answered, in 2012, by Wes himself. Yes, just use truncate.

    df.truncate(before='2012-01-07')
    

提交回复
热议问题