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

Reduce Pandas deprecation warnings. #263

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Reduce warnings like for iloc and future_stack.
Jim White committed Sep 18, 2024
commit 68b7901dc2d722706ebf9031697cb453d406aac6
2 changes: 1 addition & 1 deletion src/zipline/pipeline/loaders/earnings_estimates.py
Original file line number Diff line number Diff line change
@@ -702,7 +702,7 @@ def get_last_data_per_qtr(
ffill_across_cols(last_per_qtr, columns, self.name_map)
# Stack quarter and sid into the index.
stacked_last_per_qtr = last_per_qtr.stack(
[SID_FIELD_NAME, NORMALIZED_QUARTERS],
[SID_FIELD_NAME, NORMALIZED_QUARTERS], future_stack=True
)
# Set date index name for ease of reference
stacked_last_per_qtr.index.set_names(
33 changes: 17 additions & 16 deletions tests/pipeline/test_quarters_estimates.py
Original file line number Diff line number Diff line change
@@ -833,28 +833,29 @@ def make_loader(cls, events, columns):
def fill_expected_out(cls, expected):
# Fill columns for 1 Q out
for raw_name in cls.columns.values():
expected[raw_name + "1"].loc[
pd.Timestamp(
"2015-01-12",
) : pd.Timestamp("2015-01-19")
expected.loc[
pd.Timestamp("2015-01-12") : pd.Timestamp("2015-01-19"),
raw_name + "1"
] = cls.events[raw_name].iloc[0]
expected[raw_name + "1"].loc[pd.Timestamp("2015-01-20") :] = cls.events[
expected.loc[pd.Timestamp("2015-01-20") :, raw_name + "1"] = cls.events[
raw_name
].iloc[1]

# Fill columns for 2 Q out
for col_name in ["estimate", "event_date"]:
expected[col_name + "2"].loc[pd.Timestamp("2015-01-20") :] = cls.events[
expected.loc[pd.Timestamp("2015-01-20") :, col_name + "2"] = cls.events[
col_name
].iloc[0]
expected[FISCAL_QUARTER_FIELD_NAME + "2"].loc[
pd.Timestamp("2015-01-12") : pd.Timestamp("2015-01-20")
expected.loc[
pd.Timestamp("2015-01-12") : pd.Timestamp("2015-01-20"),
FISCAL_QUARTER_FIELD_NAME + "2"
] = 4
expected[FISCAL_YEAR_FIELD_NAME + "2"].loc[
pd.Timestamp("2015-01-12") : pd.Timestamp("2015-01-20")
expected.loc[
pd.Timestamp("2015-01-12") : pd.Timestamp("2015-01-20"),
FISCAL_YEAR_FIELD_NAME + "2"
] = 2014
expected[FISCAL_QUARTER_FIELD_NAME + "2"].loc[pd.Timestamp("2015-01-20") :] = 1
expected[FISCAL_YEAR_FIELD_NAME + "2"].loc[pd.Timestamp("2015-01-20") :] = 2015
expected.loc[pd.Timestamp("2015-01-20") :, FISCAL_QUARTER_FIELD_NAME + "2"] = 1
expected.loc[pd.Timestamp("2015-01-20") :, FISCAL_YEAR_FIELD_NAME + "2"] = 2015
return expected


@@ -2666,7 +2667,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 +2734,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 +2813,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 +2868,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