I'm trying to write a function which takes a dataframe, duplicates it, changes the values in one of the columns and then concatenates them together. For example:
df1 looks like
column1 | column2 | column3
keyword1| 1 | 20
keyword2| 1 | 40
keyword3| 1 | 60
and I want a function which creates this:
column1 | column2 | column3
keyword1| 1 | 20
keyword2| 1 | 40
keyword3| 1 | 60
keyword1| 2 | 20
keyword2| 2 | 40
keyword3| 2 | 60
I've tried this:
def add_mobile(df):
mobiledf = df.copy(deep=True)
mobiledf['column2'].replace(1,2,inplace=True)
df = pd.concat([df,mobiledf],axis=0)
however when I put df1 though this function it returns df1 unedited. If I then look at df1.shape
it has not changed.