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
2,883 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

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 in Python by Niroj
• 32,080 points
22 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,540 points
18,487 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 3, 2019 in Python by TIna
378 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 by MD 351 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 by Gitika 1,019 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
5,488 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,560 points
2,921 views
+2 votes
2 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,390 points
18,967 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
• 57,530 points
5,473 views