12

I want to duplicate a column which has numerical character in the start position. ie(1stfloor)

In simple term, I want to convert column 1stfloor to FirstFloor

df
    1stfloor
    456 
    784
    746
    44 
    9984

Tried using the below code,

df['FirstFloor'] = df['1stfloor']

encountered with below error message:

A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead

Expected output:

df

FirstFloor 
456 
784
746
44 
9984
1

1 Answer 1

28
df['FirstFloor'] = df['1stfloor'] 
df['FirstFloor'] = df.loc[:, '1stfloor']

Both worked!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.