Reputation: 2023
I have two pandas dataframe named dataset and startdate. dataset dataframe contains rows date starting from (1961 - February - 1) to (1961 - December - 31). and many years same way.
The startdate dataframe contain start day for each year such as for 1961 the start date is 1961-February-8. So I need to remove the rows from the dataset dated before start date (1961-February-8) in 1961. That means removing rows dated from (1961-February-1) to (1961-February-7). I need to do the same for all the other years. For 1961 I can do :
datset[dataset['date']>='1961-02-08']
But problem is start date from startdate for each year is different.
Upvotes: 0
Views: 77
Reputation: 323226
We do reindex
s=startdate.date.reindex(dataset['year'])
s.index=dataset.index
df=dataset[dataset['date']>=s].copy()
Upvotes: 1