oldoc63 / learningDS

Learning DS with Codecademy and Books
0 stars 0 forks source link

Performing Column Operations #380

Open oldoc63 opened 2 years ago

oldoc63 commented 2 years ago

Often the column we want to add is related to existing columns, but requires a calculation more complex than multiplication or addition.

For example, imagine that we have the following table of customers:

oldoc63 commented 2 years ago

It's a little annoying that the capitalization is different for each row. Perhaps we'd like to make it more consistent by making all of the letters uppercase.

We can use de apply function to apply a function to every value in a particular column. For example, this code overwrites the existing 'Name' columns by applying the function upper to every row in 'Name'.

oldoc63 commented 2 years ago

Apply the function lower to all names in column 'Name' in df. Assign these new names to a new column of df called 'Lowercase Name'.