Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to change the data of a particular column and multiply them depending upon the specific values in another column using pandas?

I want to select the year ‘2019/0′(string) from the column ‘year of entry’ and only multiply their ‘grades’ times 2 which is in another column

year of entry Grades
2019/0 14
2010/0 21
2019/0 15

this is what I have tried so far:

df.loc[df("Year of Entry"),'2018/9'] = df("Grades")*2

its been giving me an error and im not sure if this is the right method.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use:

df.loc[df['year of entry'].eq('2019/0'), 'Grades'] *= 2

NB. the modification is in place.

modified df:

  year of entry  Grades
0        2019/0      28
1        2010/0      21
2        2019/0      30
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading