Find the Friday of previous/last week in python

后端 未结 5 1859
闹比i
闹比i 2020-12-25 08:01

Eg1. Suppose I have a day 4/30/07 .Then I need to get 4/27/07.

Eg2. Suppose I have a day 6/29/07 .Then I need to get 6/22/07.

5条回答
  •  暖寄归人
    2020-12-25 08:50

    There are plenty of options in pandas.tseries.offsets This one is for previous week friday.

    from pandas.tseries.offsets import Week
    f_dates = required_df.index - Week(1, weekday=4)
    

提交回复
热议问题