Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 322
cam.mc Avatar asked Jun 17 '26 18:06

cam.mc


1 Answers

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

like image 62
Ajay A Avatar answered Jun 20 '26 08:06

Ajay A



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!