0

I have a main dataframe "dfnum"

I have created two dataframes from it:

dfbase = dfnum
df1 = dfnum

Now when I want to add columns to "df1" that column is also added to the other two dataframes as well:

dfbase = dfnum

df1 = dfnum

df1['A'] = (df1['B'] / (1 - df1['B']))

df1['C'] = 0.0314 * (df1['D'] / df1['B']).pow(0.5)

df1['S'] = (df1['C'] / df1['A'])

How can I solve this problem?

I am using python 3.7 and Spyder 5.0.3 both installed from Anaconda

  • 1
    You only have one dataframe in this example with 3 references to the same one. If you want to make new dataframes from an initial you should [`copy`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.copy.html) explicitly. `dfbase = dfnum.copy()` and `df1 = dfnum.copy()` – Henry Ecker Aug 02 '21 at 22:02
  • Obligatory link to [Facts and myths about Python names and values](https://nedbatchelder.com/text/names.html) – Henry Ecker Aug 02 '21 at 22:06

0 Answers0