-1
Ich bin versucht, auf den ersten Tag des nächsten Monats unter dem Datum dieser Datenrahmen abzurunden - dh 1997.10.10 würde in 1997.11.01:rundes Datum in Pandas Dataframe
Date
1997-10-10
1997-05-27
1997-04-30
1997-12-19
1997-08-12
Derzeit mein Code wie folgt aussieht:
df = pd.read_csv(XXX)
df['Date'] = pd.to_datetime(df.Date)
df['Date'] = df['Date'].dt.date.replace(day = 1)
zum python library documentation Laut,
date.replace(year=self.year, month=self.month, day=self.day)
Return a date with the same value, except for those parameters given new values by whichever keyword arguments are specified. For example, if d == date(2002, 12, 31), then d.replace(day=26) == date(2002, 12, 26).
ich vermutet hatte, dass ich konnte Verwenden Sie .replace
mit nur 1 Argument - Tag - obwohl ich eine Reihe von Fehlern erhalte.
Das ist brillant Dank! - kann jedoch keine Antwort für weitere 12 Minuten akzeptieren – christaylor