pandas.TimedeltaIndex.days # 属性 TimedeltaIndex。天[来源] # 每个元素的天数。 例子 对于系列: >>> ser = pd.Series(pd.to_timedelta([1, 2, 3], unit='d')) >>> ser 0 1 days 1 2 days 2 3 days dtype: timedelta64[ns] >>> ser.dt.days 0 1 1 2 2 3 dtype: int64 对于 TimedeltaIndex: >>> tdelta_idx = pd.to_timedelta(["0 days", "10 days", "20 days"]) >>> tdelta_idx TimedeltaIndex(['0 days', '10 days', '20 days'], dtype='timedelta64[ns]', freq=None) >>> tdelta_idx.days Index([0, 10, 20], dtype='int64')