在以下片段中,定位點的行爲與此link中所述的其餘日期不同。MonthBegin當前月份包含錨定日期
有沒有一種方法可以輕鬆地改變行爲,使其忽略定位點以表現其他日期的行爲?
在:
import pandas as pd
import numpy as np
index = pd.date_range(start = '1/1/2016', end = '1/31/2016')
index + pd.offsets.MonthBegin(0)
輸出:
DatetimeIndex(['2016-01-01', '2016-02-01', '2016-02-01', '2016-02-01',
'2016-02-01', '2016-02-01', '2016-02-01', '2016-02-01',
'2016-02-01', '2016-02-01', '2016-02-01', '2016-02-01',
'2016-02-01', '2016-02-01', '2016-02-01', '2016-02-01',
'2016-02-01', '2016-02-01', '2016-02-01', '2016-02-01',
'2016-02-01', '2016-02-01', '2016-02-01', '2016-02-01',
'2016-02-01', '2016-02-01', '2016-02-01', '2016-02-01',
'2016-02-01', '2016-02-01', '2016-02-01'],
dtype='datetime64[ns]', freq=None)
通知的第一個日期2016年1月1日是如何不同,因爲它是一個錨點?我可以修改行爲,使其在偏移量的應用中保持一致嗎? –
我可以寫一個客戶功能。我只是想知道是否有東西已經內置。我有一個場景,我有一個隨機日期一堆,我想每個日期設置爲每個月的第一天的字段。 –