From 43e847ff2f95bb64d2dae14dd7e1e349dcca4265 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 27 Sep 2022 08:02:51 +0000 Subject: [PATCH] Update to pandas 1.5.0 syntax, avoiding warnings --- freqtrade/data/btanalysis.py | 6 +++--- freqtrade/optimize/optimize_reports.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/freqtrade/data/btanalysis.py b/freqtrade/data/btanalysis.py index 9e38f6833..accb92e42 100644 --- a/freqtrade/data/btanalysis.py +++ b/freqtrade/data/btanalysis.py @@ -341,9 +341,9 @@ def trade_list_to_dataframe(trades: List[LocalTrade]) -> pd.DataFrame: """ df = pd.DataFrame.from_records([t.to_json(True) for t in trades], columns=BT_DATA_COLUMNS) if len(df) > 0: - df.loc[:, 'close_date'] = pd.to_datetime(df['close_date'], utc=True) - df.loc[:, 'open_date'] = pd.to_datetime(df['open_date'], utc=True) - df.loc[:, 'close_rate'] = df['close_rate'].astype('float64') + df['close_date'] = pd.to_datetime(df['close_date'], utc=True) + df['open_date'] = pd.to_datetime(df['open_date'], utc=True) + df['close_rate'] = df['close_rate'].astype('float64') return df diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index 6c4dbcfef..8dafe2e41 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -173,7 +173,7 @@ def generate_tag_metrics(tag_type: str, tabular_data = [] if tag_type in results.columns: - for tag, count in results[tag_type].value_counts().iteritems(): + for tag, count in results[tag_type].value_counts().items(): result = results[results[tag_type] == tag] if skip_nan and result['profit_abs'].isnull().all(): continue @@ -199,7 +199,7 @@ def generate_exit_reason_stats(max_open_trades: int, results: DataFrame) -> List """ tabular_data = [] - for reason, count in results['exit_reason'].value_counts().iteritems(): + for reason, count in results['exit_reason'].value_counts().items(): result = results.loc[results['exit_reason'] == reason] profit_mean = result['profit_ratio'].mean() @@ -361,7 +361,7 @@ def generate_daily_stats(results: DataFrame) -> Dict[str, Any]: winning_days = sum(daily_profit > 0) draw_days = sum(daily_profit == 0) losing_days = sum(daily_profit < 0) - daily_profit_list = [(str(idx.date()), val) for idx, val in daily_profit.iteritems()] + daily_profit_list = [(str(idx.date()), val) for idx, val in daily_profit.items()] return { 'backtest_best_day': best_rel,