-1

I have a column in my dataset called "Published" that looks like the attached picture below. How do I group them by weeks so I can see all of the unique weeks of this column? Output should look something like: 2017-11-06 2017-11-13 2017-11-20 ...

My Column "Published"

  • See [here](https://stackoverflow.com/q/51105216/8881141) or [here](https://stackoverflow.com/q/45281297/8881141) or [here](https://stackoverflow.com/q/59246839/8881141) or... – Mr. T Jan 15 '22 at 08:31

1 Answers1

0
df.set_index('Date')
df.resample('W').agg({'column_name':'agg_function'})
  • This did not help. I'm getting TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex' – nodoctor123 Jan 15 '22 at 23:38
  • @Pikacho Yo [Datetime](https://youtu.be/UFuo7EHI8zc) series tutorial .Also refer Pandas documentation (https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior) for help – FAISAL BARGI Jan 16 '22 at 05:16