Skip to content

Up-sampling and filling while also passing the "how" parameter #2073

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
danxshap opened this issue Oct 15, 2012 · 0 comments · Fixed by #7341
Closed

Up-sampling and filling while also passing the "how" parameter #2073

danxshap opened this issue Oct 15, 2012 · 0 comments · Fixed by #7341
Labels
Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Resample resample method
Milestone

Comments

@danxshap
Copy link
Contributor

I'm up-sampling quarterly data to monthly periods and using a fill method which is working fine, but then when I pass in an argument for "how", it seems to disable the filling feature.

My understanding was that "how" doesn't mean anything in the context of up-sampling, in which case I would expect passing the parameter to have no effect on the output.

Is this a bug or am I missing something about how this is supposed to work?

See below (pandas 0.8.1):

In [18]: s = pandas.Series(range(9), index=pandas.date_range('2010-01-01', periods=9, freq='Q'))

In [19]: s
Out[19]: 
2010-03-31    0
2010-06-30    1
2010-09-30    2
2010-12-31    3
2011-03-31    4
2011-06-30    5
2011-09-30    6
2011-12-31    7
2012-03-31    8
Freq: Q-DEC

In [20]: s.resample('M', fill_method='ffill')
Out[20]: 
2010-03-31    0
2010-04-30    0
2010-05-31    0
2010-06-30    1
2010-07-31    1
2010-08-31    1
2010-09-30    2
2010-10-31    2
2010-11-30    2
2010-12-31    3
2011-01-31    3
2011-02-28    3
2011-03-31    4
2011-04-30    4
2011-05-31    4
2011-06-30    5
2011-07-31    5
2011-08-31    5
2011-09-30    6
2011-10-31    6
2011-11-30    6
2011-12-31    7
2012-01-31    7
2012-02-29    7
2012-03-31    8
Freq: M

In [21]: s.resample('M', fill_method='ffill', how='last')
Out[21]: 
2010-03-31     0
2010-04-30   NaN
2010-05-31   NaN
2010-06-30     1
2010-07-31   NaN
2010-08-31   NaN
2010-09-30     2
2010-10-31   NaN
2010-11-30   NaN
2010-12-31     3
2011-01-31   NaN
2011-02-28   NaN
2011-03-31     4
2011-04-30   NaN
2011-05-31   NaN
2011-06-30     5
2011-07-31   NaN
2011-08-31   NaN
2011-09-30     6
2011-10-31   NaN
2011-11-30   NaN
2011-12-31     7
2012-01-31   NaN
2012-02-29   NaN
2012-03-31     8
Freq: M
@jreback jreback modified the milestones: 0.14.1, Someday May 29, 2014
hayd added a commit to hayd/pandas that referenced this issue May 30, 2014
cpcloud added a commit that referenced this issue Jun 4, 2014
FIX: resample with fill_method and how #2073
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate Resample resample method
Projects
None yet
2 participants