Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)
Let's say, I have two columns of a pandas dataframe. I need to change the estimations of the first column without influencing the subsequent one and get back the entire dataframe with simply first column values to be changed. How might I do that utilizing apply in pandas?

1 Answer

0 votes
by (26.4k points)

Assume the below dataframe df as:

a,b

1,2

2,3

3,4

4,5

and you expect:

df['a'] = df['a'].apply(lambda x: x + 1)

which returns:

   a  b

0  2  2

1  3  3

2  4  4

3  5  5

Interested to learn python in detail? Come and Join the python course.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...