froggleston/freqtrade_analysis_notebook

AttributeError: 'DataFrame' object has no attribute 'append' & AttributeError: 'Series' object has no attribute 'iteritems'

vaidab opened this issue · 1 comments

vaidab commented

Fixed provided below, will commit to another pull request. Note that I'm not familiar with this section of the code, would appreciate some testing on your side.

AttributeError: 'DataFrame' object has no attribute 'append'


AttributeError Traceback (most recent call last)
/tmp/ipykernel_1810/2443414422.py in ?()
78 # reset config_i
79 new_srs_tuple = (srs[0], srs[1], srs[2], srs[3], 1, srs[5])
80 redo_results.append(new_srs_tuple)
81
---> 82 load_strategy_comparison, load_strategy_trades, load_strategy_signal_candles = notebook_helper.prepare_results(redo_config, redo_results)
83 notebook_helper.print_quant_stats(redo_config, load_strategy_comparison, load_strategy_trades, table=True, output='user_data/notebooks/{strategy}-vs-{benchmark}.html')
84
85 br_comparison = load_strategy_comparison

/freqtrade/notebooks/notebook_helper.py in ?(test_config, results)
363 strategy_signal_candles[config['strategy']][pair] = DataFrame()
364
365 if processed_dfs[config['strategy']][pair].shape[0] > 0:
366 processed_dfs[config['strategy']][pair].set_index('date', drop=False)
--> 367 strategy_signal_candles[config['strategy']][pair] = strategy_signal_candles[config['strategy']][pair].append(processed_dfs[config['strategy']][pair], ignore_index=True)
368
369 # Join trade dataframes
370 for config_i, info in strategy_trades.items():

~/.local/lib/python3.11/site-packages/pandas/core/generic.py in ?(self, name)
5985 and name not in self._accessors
5986 and self._info_axis._can_hold_identifiers_and_holds_name(name)
5987 ):
5988 return self[name]
-> 5989 return object.getattribute(self, name)

AttributeError: 'DataFrame' object has no attribute 'append'

I can fix it with:

strategy_signal_candles[config['strategy']][pair] = pd.concat([strategy_signal_candles[config['strategy']][pair], processed_dfs[config['strategy']][pair]], ignore_index=True)

Then I get: AttributeError: 'Series' object has no attribute 'iteritems'


AttributeError Traceback (most recent call last)
/tmp/ipykernel_1810/2443414422.py in ?()
78 # reset config_i
79 new_srs_tuple = (srs[0], srs[1], srs[2], srs[3], 1, srs[5])
80 redo_results.append(new_srs_tuple)
81
---> 82 load_strategy_comparison, load_strategy_trades, load_strategy_signal_candles = notebook_helper.prepare_results(redo_config, redo_results)
83 notebook_helper.print_quant_stats(redo_config, load_strategy_comparison, load_strategy_trades, table=True, output='user_data/notebooks/{strategy}-vs-{benchmark}.html')
84
85 br_comparison = load_strategy_comparison

/freqtrade/notebooks/notebook_helper.py in ?(test_config, results)
370
371 # Join trade dataframes
372 for config_i, info in strategy_trades.items():
373 info.trades = pd.concat(info.trades)
--> 374 info.qs_trades = trades_freq2quant(info.trades, info.config)
375
376 # TODO: Save merge results of multiple backtests and save them
377 # stats = generate_backtest_stats(data, self.all_results, min_date=min_date, max_date=max_date)

/freqtrade/notebooks/notebook_helper.py in ?(series, config)
132 daily_profit = daily_profit.set_axis(t)
133
134 # Generate daily wallet value
135 value = config['dry_run_wallet']
--> 136 for d in daily_profit.iteritems():
137 value = value + d[1]
138 daily_profit.at[d[0]] = value
139

~/.local/lib/python3.11/site-packages/pandas/core/generic.py in ?(self, name)
5985 and name not in self._accessors
5986 and self._info_axis._can_hold_identifiers_and_holds_name(name)
5987 ):
5988 return self[name]
-> 5989 return object.getattribute(self, name)

AttributeError: 'Series' object has no attribute 'iteritems'

My fix:

        for index, profit in daily_profit.items():
            value += profit
            daily_profit.at[index] = value