H there,
I would like to Backfill, NaN Values For a given Column, i.e. in this case 'Date', and for a Particular Date from that Column.
I have allready Forward Filled for missing Dates, in my DataFrame in Pandas. I am working with an Excel .xls File , in my DataFrame in Pandas, using Jupyter Notebook.
This is the Line Of Code I used :-
df["Date"].fillna(method='ffill', inplace = True)
But I would like to narrow that down to a particular Date, this time back filling.
Could someone tell me, what I should type to do that ?
Any help would be appreciated
Regards
Eddie Winch
What I have tried:
This is the Date Sorting part of my Code :-
<pre>#return df['Durn'] column datetime64 format to object type
df['Durn'] = pd.to_datetime(df['Durn'], format='%H:%M:%S').dt.time
#print("reverted datatype of column Durn back to ----->",df['Durn'].dtype)
#print("=======")
#print("\n\n*** FINAL RESULTSET ***\n\n")
df['Date']= pd.to_datetime(df['Date'],format='%Y-%m-%d')
#df['Date']= pd.to_datetime(df['Date']).dt.strftime('%d-%m-%Y')
##added two lines above to convert date format
df['Date'] = df['Date'].mask(df['Date'].dt.year == 2008,
df['Date'] + pd.offsets.DateOffset(year=2009))
df=df.loc[df.Date.dt.strftime('%m%d').astype(int).argsort()]
df['Date']= pd.to_datetime(df['Date']).dt.strftime('%d-%m-%Y')
pd.DataFrame(df)