pandas fill in missing data
Go to solution
Solved by vorticalbox,
40 minutes ago, tikker said:Ah yeah Pandas is neat like that.
I have found a better way
create a second data frame from start to end of the first, fill with 0 then merge with the original df
payments = pd.read_csv('payments.csv', header=0) df = pd.DataFrame() df['ds'] = pd.to_datetime(payments['date']) df['y'] = payments['total'] df2 = pd.DataFrame((pd.date_range(start=df.ds.min(), end=df.ds.max(), freq='1D')), columns=["ds"]) df = pd.merge(df2, df, on="ds", how="left").fillna(0)

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now