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 in Python by Rishi
96 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 by John

Related Questions In Python

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,520 points
8,172 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 in Python by TIna
94 views
0 votes
1 answer

How to create empty pandas dataframe only with column names?

You can do it like this: df=pd.DataFrame(columns=["Name","Old","New ...READ MORE

answered Apr 5 in Python by Hari
497 views
0 votes
1 answer

How to rename columns in pandas (Python)?

It is easy by just adding ".columns" ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points
133 views
0 votes
1 answer

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

The major difference is size includes NaN ...READ MORE

answered Apr 30, 2018 in Data Analytics by DeepCoder786
• 1,720 points
754 views
0 votes
2 answers
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,550 points
1,630 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,350 points
7,627 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
• 56,920 points
2,056 views