Python Forum
FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries
#1
This is with pandas dataframes. The code works, but I am getting a warning.

Error:
C:\Users\thpfs\documents\python\cleaner.py:223: FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries is deprecated. In a future version, this will no longer exclude empty or all-NA columns when determining the result dtypes. To retain the old behavior, exclude the relevant entries before the concat operation. (entrance_pricediff < 0 and pre_removal_df['price'].iloc[-1] + clean_baseprice < pre_removal_df['price_next'].iloc[-1]): removal_df = removal_df._append(pre_removal_df)
So I think I know why I'm getting that error.

if (entrance_pricediff > 0 and pre_removal_df['price'].iloc[-1] - clean_baseprice > pre_removal_df['price_next'].iloc[-1]) or \
                       (entrance_pricediff < 0 and pre_removal_df['price'].iloc[-1] + clean_baseprice < pre_removal_df['price_next'].iloc[-1]): removal_df = removal_df._append(pre_removal_df)
I have the above code inside of a for loop. If the condition for my if statement is met, then I want to append pre_removal_df to removal_df. At the start of the loop removal_df is empty, however I need to declare removal_df ahead of time because I can't ._append() to a dataframe that isn't previously declared. removal_df is declared as an empty dataframe with all of the same columns as pre_removal_df.

So because on the first go of my for loop I am appending to an empty dataframe, I am getting that warning.

I am wondering if there is a more "proper" way to do this, instead of declaring an empty dataframe and then just appending to it... by "do this" I mean having a loop where each iteration may potentially append one dataframe to another.

Thank you.
Reply


Messages In This Thread
FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries - by sawtooth500 - Apr-21-2024, 06:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  FutureWarning: The behavior of DataFrame concatenation with empty or all-NA entries i sawtooth500 3 1,799 Mar-22-2024, 03:08 AM
Last Post: deanhystad
  String concatenation in SQL update statement hammer 3 1,587 Feb-24-2022, 08:00 PM
Last Post: hammer
  f string concatenation problem growSeb 3 2,311 Jun-28-2021, 05:00 AM
Last Post: buran
  Concatenation ?? ridgerunnersjw 1 1,760 Sep-26-2020, 07:29 PM
Last Post: deanhystad
  FutureWarning: pandas.util.testing is deprecated buunaanaa 3 5,164 May-17-2020, 07:43 AM
Last Post: snippsat
  Combining two strings together (not concatenation) DreamingInsanity 6 3,194 Mar-29-2019, 04:32 PM
Last Post: DreamingInsanity
  Handling null or empty entries from Entry Widget KevinBrown 1 2,341 Mar-17-2019, 04:22 PM
Last Post: perfringo
  append elements into the empty dataframe jazzy 0 2,141 Sep-26-2018, 07:26 AM
Last Post: jazzy
  Regarding concatenation of a list to a string Kedar 2 22,840 Aug-19-2018, 12:57 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020