pythondataframeqtconsole

Using describe() method to exclude a column


I am new to using python with data sets and am trying to exclude a column ("id") from being shown in the output. Wondering how to go about this using the describe() and exclude functions.


Solution

  • describe works on the datatypes. You can include or exclude based on the datatype & not based on columns. If your column id is of unique data type, then

    df.describe(exclude=[datatype])
    

    or if you just want to remove the column(s) in describe, then try this

    cols = set(df.columns) - {'id'}
    df1 = df[list(cols)]
    df1.describe()
    

    TaDa its done. For more info on describe click here