diff --git a/src/zipline/_protocol.pyx b/src/zipline/_protocol.pyx index d3aef4919b..dceb11b293 100644 --- a/src/zipline/_protocol.pyx +++ b/src/zipline/_protocol.pyx @@ -659,7 +659,7 @@ cdef class BarData: df = (pd.concat(df_dict, keys=df_dict.keys(), names=['fields', dt_label]) - .stack(dropna=False) # ensure we return all fields/assets/dates despite missing values + .stack(future_stack=True) # ensure we return all fields/assets/dates despite missing values .unstack(level='fields')) df.index.set_names([dt_label, 'asset']) return df.sort_index() diff --git a/src/zipline/data/data_portal.py b/src/zipline/data/data_portal.py index d637195b57..6a3fd68751 100644 --- a/src/zipline/data/data_portal.py +++ b/src/zipline/data/data_portal.py @@ -948,7 +948,7 @@ def get_history_window( df.iloc[0, assets_with_leading_nan] = np.array( initial_values, dtype=np.float64 ) - df.fillna(method="ffill", inplace=True) + df.ffill(inplace=True) # forward-filling will incorrectly produce values after the end of # an asset's lifetime, so write NaNs back over the asset's diff --git a/src/zipline/pipeline/loaders/earnings_estimates.py b/src/zipline/pipeline/loaders/earnings_estimates.py index 3e815735b4..f6e076297b 100644 --- a/src/zipline/pipeline/loaders/earnings_estimates.py +++ b/src/zipline/pipeline/loaders/earnings_estimates.py @@ -703,6 +703,7 @@ def get_last_data_per_qtr( # Stack quarter and sid into the index. stacked_last_per_qtr = last_per_qtr.stack( [SID_FIELD_NAME, NORMALIZED_QUARTERS], + future_stack=True, ) # Set date index name for ease of reference stacked_last_per_qtr.index.set_names( diff --git a/tests/pipeline/test_international_markets.py b/tests/pipeline/test_international_markets.py index 54133e75d9..7c96c88907 100644 --- a/tests/pipeline/test_international_markets.py +++ b/tests/pipeline/test_international_markets.py @@ -128,7 +128,10 @@ def init_class_fixtures(cls): bar_data = cls.daily_bar_data[name] df = ( - pd.concat(bar_data, keys=bar_data.keys()).stack().unstack(0).swaplevel() + pd.concat(bar_data, keys=bar_data.keys()) + .stack(future_stack=True) + .unstack(0) + .swaplevel() ) frames = { field: frame.reset_index(level=0, drop=True) diff --git a/tests/pipeline/test_quarters_estimates.py b/tests/pipeline/test_quarters_estimates.py index 1a613d0185..91d4c3c18e 100644 --- a/tests/pipeline/test_quarters_estimates.py +++ b/tests/pipeline/test_quarters_estimates.py @@ -2666,7 +2666,7 @@ def make_expected_out(cls): .set_index(SID_FIELD_NAME, append=True) .unstack(SID_FIELD_NAME) .reindex(cls.trading_days) - .stack(SID_FIELD_NAME, dropna=False) + .stack(SID_FIELD_NAME, future_stack=True) ) split_adjusted_at_end_boundary = ( @@ -2733,7 +2733,7 @@ def make_expected_out(cls): .set_index(SID_FIELD_NAME, append=True) .unstack(SID_FIELD_NAME) .reindex(cls.trading_days) - .stack(SID_FIELD_NAME, dropna=False) + .stack(SID_FIELD_NAME, future_stack=True) ) split_adjusted_before_start_boundary = split_adjusted_at_start_boundary @@ -2812,7 +2812,7 @@ def make_expected_out(cls): .set_index(SID_FIELD_NAME, append=True) .unstack(SID_FIELD_NAME) .reindex(cls.trading_days) - .stack(SID_FIELD_NAME, dropna=False) + .stack(SID_FIELD_NAME, future_stack=True) ) split_adjusted_at_end_boundary = ( @@ -2867,7 +2867,7 @@ def make_expected_out(cls): .set_index(SID_FIELD_NAME, append=True) .unstack(SID_FIELD_NAME) .reindex(cls.trading_days) - .stack(SID_FIELD_NAME, dropna=False) + .stack(SID_FIELD_NAME, future_stack=True) ) split_adjusted_before_start_boundary = split_adjusted_at_start_boundary