Apr-21-2024, 06:16 PM
This is with pandas dataframes. The code works, but I am getting a warning.
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.
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.