Global Data Science Forum

Expand all | Collapse all

Display the data types of each column using the attribute dtype, then take a screenshot and submit it, include your code in the image.

  • 1.  Display the data types of each column using the attribute dtype, then take a screenshot and submit it, include your code in the image.

    Posted Fri February 19, 2021 11:57 AM

    Can someone guide me how to solve this question? thanks in advance

    ------------------------------
    Shahzad Nadeem
    ------------------------------


  • 2.  RE: Display the data types of each column using the attribute dtype, then take a screenshot and submit it, include your code in the image.

    Posted Mon February 22, 2021 01:14 AM
    if you want to see all the data types in a dataframe, use df.dtypes 

    ------------------------------
    Aparna Mookerjee
    ------------------------------



  • 3.  RE: Display the data types of each column using the attribute dtype, then take a screenshot and submit it, include your code in the image.

    Posted Mon February 22, 2021 01:14 AM
    Edited by Ratnesh gupta Mon February 22, 2021 01:14 AM
    Hi Shahzad,

    please remove parenthesis 

    df.dtypes


    Regards
    Ratnesh Gupta

    ------------------------------
    Ratnesh gupta
    Team Lead
    IBM India Pvt Ltd
    Noida
    ------------------------------



  • 4.  RE: Display the data types of each column using the attribute dtype, then take a screenshot and submit it, include your code in the image.

    Posted Mon February 22, 2021 10:43 AM

    dtype is an attribute.

    Attributes are not called with parentheses 


    call it by df.dtypes



    ------------------------------
    Mark Seguerra
    ------------------------------



  • 5.  RE: Display the data types of each column using the attribute dtype, then take a screenshot and submit it, include your code in the image.

    Posted Mon February 22, 2021 10:43 AM
    Remove the brackets. It should be df.dtypes.. You should be fine

    ------------------------------
    Chandresh Khaneja
    ------------------------------



  • 6.  RE: Display the data types of each column using the attribute dtype, then take a screenshot and submit it, include your code in the image.

    Posted Mon February 22, 2021 10:55 AM
    print(df.dtypes)
     ....
    This should work

    ------------------------------
    Ashish Singh
    Desktop Engineer
    Hawkeyetechworld
    Borivali
    8850220698
    ------------------------------



  • 7.  RE: Display the data types of each column using the attribute dtype, then take a screenshot and submit it, include your code in the image.

    Posted Mon February 22, 2021 11:09 AM
    Hello Shahzad; 

    I'm a fellow learner, and am very new to even basic pandas and all other python capabilities for data analysis.
    But I think I have an idea to give. I can't see which imports you did up there before reading the csv file, but assuming you had imported pandas and numpy. 
    I think the next step is to define your rows and columns. df.dtypes() should be defining your columns. So I guess you should be writing a line defining your columns in the data frame, in the form of key-value pairs of a dictionary where as keys should be representing the column names and the values the values is value of the row matching that column (or at least that's how I got it). Like this:
    df = pd.DataFrame({'ibm':['is'], 'the':['number'], 'one':['IT'], 'company': ['ever']})

    and then;
    df.dtypes should give you the "types and bits" of the input data for the columns: "ibm", "the", "one" and "company".

    I'd try this on the terminal (cmd) to see if it works and then put it on the jupyter accordingly. Let me know if it doesn't work

    ------------------------------
    Emirhan Bilim
    ------------------------------