isds2020 icon indicating copy to clipboard operation
isds2020 copied to clipboard

Question regarding 0.4.2

Open danielarmel opened this issue 5 years ago • 4 comments
trafficstars

Hi! I'm a little confused about exercise 0.4.2

We are supposed to rename the columns, but how do you only select the first four columns? I've tried iloc and loc, but that doesn't "change" the length of df_weather

danielarmel avatar Jul 27 '20 14:07 danielarmel

hi @danielarmel , have you tried by first subsetting the dataframe like this? iloc

jsr-p avatar Jul 27 '20 15:07 jsr-p

I have, it changes it when I write the code:

image

But my problem is that it doesn't "save" these changes. When I try to rename them, I get this error:

image image

Which makes sense as the length of the list is still 8, while I try to rename only 4 columns.. I can't seem to figure out how to make the subset permanent

danielarmel avatar Jul 27 '20 16:07 danielarmel

You will have to store the subsetted dataframe in a new variable before changing the column names :) As your code is now you only inspect the subsetted dataframe. In the following line where you try to change the column names you use the original dataframe which has 8 columns.

jsr-p avatar Jul 27 '20 16:07 jsr-p

That fixed it, thanks!

danielarmel avatar Jul 27 '20 16:07 danielarmel