0

I am trying to create a Calendar Heatmap looking at a sport team's Attendance by Date.

Sample DF

The Date column is an 'Object' so I tried a very lazy attempt at using "df['Date'] = pd.to_datetime(df['Date'])" but I would get the error of "Out of bounds nanosecond timestamp: 1-04-07 00:00:00".

I've also tried changing the format of 'Thursday, Apr 7' using something along the lines of "strftime('%m,%d,%Y')" but then I would get errors saying something about unable to work on Series.

I am lost in what to do next. I'm hoping someone can assist me in this.

FObersteiner
  • 22,500
  • 8
  • 42
  • 72
  • 1
    Please provide a reproducible version of your dataframe, as can be seen here https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples it's hard for us to help you when you don't give us anything to work with! – Nicholas Hansen-Feruch Nov 01 '22 at 18:30
  • The out of bounds nanosecond timestamp means one or more of your dates is less than `pd.Timestamp.min` or greater than `pd.Timestamp.max`. `strftime()` outputs datetime objects as formatted strings, so that doesn't work unless your dates are already in datetime format, and it only works on individual dates, not columns. Try checking the type of your data using `type(df['Date'][0])` – Vincent Rupp Nov 01 '22 at 18:39
  • Please provide a list of strings that you are trying to convert to datetime. – Scott Boston Nov 01 '22 at 18:40
  • Also, please provide sample data (and code) as text, not image. In general, to parse a date like "Thursday, Apr 7", you should probably provide a `format="%A, %b %d"` to pd.to_datetime. – FObersteiner Nov 01 '22 at 19:43

0 Answers0