Skip to content
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

Fix warnings related to Pandas 2.1.0 #260

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/zipline/_protocol.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/zipline/data/data_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/zipline/pipeline/loaders/earnings_estimates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion tests/pipeline/test_international_markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions tests/pipeline/test_quarters_estimates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = (
Expand Down Expand Up @@ -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
Expand Down
Loading