Using describe() method to exclude a column
Question:
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.
Answers:
Use output.describe(exclude=['id'])
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
You can do that by slicing your original DF and remove the ‘id’ column. One way is through .iloc
. Let’s suppose the column ‘id’ is the first column from you DF, then, you could do this:
df.iloc[:,1:].describe()
The first colon represents the rows, the second the columns.
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.
Use output.describe(exclude=['id'])
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
You can do that by slicing your original DF and remove the ‘id’ column. One way is through .iloc
. Let’s suppose the column ‘id’ is the first column from you DF, then, you could do this:
df.iloc[:,1:].describe()
The first colon represents the rows, the second the columns.