Skip to content

Fixed pandas FutureWarning #1073

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

Merged
merged 3 commits into from
Apr 27, 2022
Merged
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
4 changes: 2 additions & 2 deletions qlib/contrib/report/analysis_position/parse_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ def parse_position(position: dict = None) -> pd.DataFrame:
if not _trading_day_sell_df.empty:
_trading_day_sell_df["status"] = -1
_trading_day_sell_df["date"] = _trading_date
_trading_day_df = _trading_day_df.append(_trading_day_sell_df, sort=False)
_trading_day_df = pd.concat([_trading_day_df, _trading_day_sell_df], sort=False)

result_df = result_df.append(_trading_day_df, sort=True)
result_df = pd.concat([result_df, _trading_day_df], sort=True)

previous_data = dict(
date=_trading_date,
Expand Down
2 changes: 1 addition & 1 deletion qlib/contrib/report/analysis_position/risk_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _get_monthly_risk_analysis_with_report(report_normal_df: pd.DataFrame) -> pd
# _m_report_long_short,
pd.Timestamp(year=gp_m[0], month=gp_m[1], day=month_days),
)
_monthly_df = _monthly_df.append(_temp_df, sort=False)
_monthly_df = pd.concat([_monthly_df, _temp_df], sort=False)

return _monthly_df

Expand Down
2 changes: 1 addition & 1 deletion scripts/data_collector/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def save_instrument(self, symbol, df: pd.DataFrame):
df["symbol"] = symbol
if instrument_path.exists():
_old_df = pd.read_csv(instrument_path)
df = _old_df.append(df, sort=False)
df = pd.concat([_old_df, df], sort=False)
df.to_csv(instrument_path, index=False)

def cache_small_data(self, symbol, df):
Expand Down
2 changes: 1 addition & 1 deletion scripts/data_collector/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def parse_instruments(self):
] = _row.date
else:
_tmp_df = pd.DataFrame([[_row.symbol, self.bench_start_date, _row.date]], columns=instruments_columns)
new_df = new_df.append(_tmp_df, sort=False)
new_df = pd.concat([new_df, _tmp_df], sort=False)

inst_df = new_df.loc[:, instruments_columns]
_inst_prefix = self.INST_PREFIX.strip()
Expand Down
4 changes: 2 additions & 2 deletions scripts/data_collector/yahoo/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def download_index_data(self):
_path = self.save_dir.joinpath(f"sh{_index_code}.csv")
if _path.exists():
_old_df = pd.read_csv(_path)
df = _old_df.append(df, sort=False)
df = pd.concat([_old_df, df], sort=False)
df.to_csv(_path, index=False)
time.sleep(5)

Expand Down Expand Up @@ -404,7 +404,7 @@ def normalize_yahoo(
.index
)
df.sort_index(inplace=True)
df.loc[(df["volume"] <= 0) | np.isnan(df["volume"]), set(df.columns) - {symbol_field_name}] = np.nan
df.loc[(df["volume"] <= 0) | np.isnan(df["volume"]), list(set(df.columns) - {symbol_field_name})] = np.nan

change_series = YahooNormalize.calc_change(df, last_close)
# NOTE: The data obtained by Yahoo finance sometimes has exceptions
Expand Down