• Fwd: Can you help me with this Python question?

    From Sarah Wallace@21:1/5 to All on Thu Oct 13 07:44:04 2022
    For a python class I am taking..

    In this challenge, you'll be working with a DataFrame that contains data
    about artworks, and it contains many missing values.

    Your task is to create a variable called na_sum that contains the total
    number of missing values in the DataFrame. When that's completed, print out your answer!

    Hint: The code given below will give you the number of missing (NaN) values
    for the *Name* column in the DataFrame. How would you edit the code to get
    the missing values for every column in the DataFrame?
    Extra hint: You'll be returning a single number which is the final sum() of everything.

    df['Name'].isnull().sum()

    --
    Thanks!

    *Sarah Wallace*
    [email protected]




    --
    Thanks!

    *Sarah Wallace*
    [email protected]
    214.300.1064

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Axy@21:1/5 to Sarah Wallace on Thu Oct 13 18:47:32 2022
    Well, although I never used pandas and never will, if that's about
    artworks, that's mine.

    Obviously, you need to iterate columns and sum values returned by the
    snippet you provided. A quick search tells us to use colums property.
    So, it might look like this:

    na_sum = sum(df[name].isnull().sum() for name in df.columns)

    Axy

    On 13/10/2022 13:44, Sarah Wallace wrote:
    For a python class I am taking..

    In this challenge, you'll be working with a DataFrame that contains data about artworks, and it contains many missing values.

    Your task is to create a variable called na_sum that contains the total number of missing values in the DataFrame. When that's completed, print out your answer!

    Hint: The code given below will give you the number of missing (NaN) values for the *Name* column in the DataFrame. How would you edit the code to get the missing values for every column in the DataFrame?
    Extra hint: You'll be returning a single number which is the final sum() of everything.

    df['Name'].isnull().sum()


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)