DataFrame.truncate(before=None, after=None, axis=None, copy=True)[source]
在某个索引值之前和之后Truncate Series或DataFrame。
这是基于高于或低于某些阈值的索引值,进行布尔索引的有用捷径。
参数:before:date, str, int
Truncate此索引值之前的所有行。
after :date, str, int
Truncate此索引值之后的所有行。
axis :{0或‘index’, 1或‘columns’}, 可选。
Truncate轴。默认情况下Truncate索引(行)。
copy :bool, 默认为 True
返回truncated部分的副本。
返回值:调用者的type
truncated Series或DataFrame。
Notes
如果被truncate的索引仅包含日期时间值,则 可以将字符串之前和之后指定为字符串,而不是时间戳。
例子>>> df = pd.DataFrame({'A': ['a', 'b', 'c', 'd', 'e'],
... 'B': ['f', 'g', 'h', 'i', 'j'],
... 'C': ['k', 'l', 'm', 'n', 'o']},
...