I need help on a python exercise I have to do

With this function named extraer_peso
The function must recive as parameter a DataFrame and must give back a DataFrame
The incoming DataFrame has a column named ‘altura’ that is type object
the outcoming DataFrame has a column named ‘altura’ of float64 type

def extraer_altura(df):
    # Here  i must put the code 
    # I can not change this lines
    assert(isinstance(df, pd.DataFrame))
    return df

Thank you

Welcome to the forum!

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

Please use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks are not single quotes.

markdown_Forums

2 Likes

Welcome, Mikel.

What are you specifically struggling to with?

1 Like

Thanks,

Im starting my way to understand python.
I have an exercise where I read a csv file where one of the columns is ‘Altura’, (height) and is object type.
They ask me with the structure I wrote above to change it to a column keeping the same name ('altura) but float64.

I suggest you Google: python object to float64

There is a lot of info out there.

1 Like