How to replace entire column in pandas dataframe

0 votes

I have the following pandas dataframe

  Name Age  New

0 Mike 23  NaN

1 Eric 25  NaN

2 Donna 23  NaN

3 Will 23  NaN

Now I want to replace the column New with the values in column Age. How can I do this?

May 8, 2019 in Python by Rishi
13,856 views

1 answer to this question.

0 votes

Use the dataframe with respective column names and assignment operator, like this:

df[‘New’]=df[‘Age’]
answered May 8, 2019 by John
Thanks Guys. It really helped

Related Questions In Python

0 votes
1 answer

How to count the NaN values in a column in pandas DataFrame?

Hello @kartik, Lets assume df is a pandas DataFrame. Then, df.isnull().sum(axis = ...READ MORE

answered Jun 15, 2020 in Python by Niroj
• 82,840 points
1,798 views
0 votes
1 answer

How to convert a Pandas GroupBy object to DataFrame in Python

g1 here is a DataFrame. It has a hierarchical index, ...READ MORE

answered Nov 12, 2018 in Python by Nymeria
• 3,560 points
34,445 views
0 votes
1 answer
0 votes
1 answer

How to print just one column in pandas?

You can use the header to print ...READ MORE

answered Apr 4, 2019 in Python by TIna
10,805 views
0 votes
1 answer

How to rename columns in pandas (Python)?

You can use the rename function in ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8, 2020 by MD 2,049 views
0 votes
1 answer

What is the Difference in Size and Count in pandas (python)?

The major difference is "size" includes NaN values, ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points

edited Jun 8, 2020 by Gitika 2,850 views
0 votes
2 answers

Replacing a row in pandas data.frame

key error. I love python READ MORE

answered Feb 18, 2019 in Data Analytics by anonymous
13,737 views
0 votes
1 answer

Converting a pandas data-frame to a dictionary

Emp_dict=Employee.to_dict('records') You can directly use the 'to_dict()' function ...READ MORE

answered May 23, 2018 in Data Analytics by Bharani
• 4,660 points
4,571 views
+2 votes
4 answers

How can I replace values with 'none' in a dataframe using pandas

Actually in later versions of pandas this ...READ MORE

answered Aug 13, 2018 in Python by bug_seeker
• 15,510 points
122,280 views
0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 58,020 points
11,711 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP