When I use
df.describe().to_csv("data.csv", index=False)
I get the results for each column but the first column with the descriptions of each row is missing.
So I can't see in the csv which value describes what.
count
mean
std
...
is missing.
How can I get that column as the first column in my csv export like I see it when using
print(df.describe())
You are excluding the index:
df.describe().to_csv("data.csv", index=False)
The label on each row in the describe()
output is an index value:
>>> df.describe().index
Index(['count', 'mean', 'std', 'min', '25%', '50%', '75%', 'max'], dtype='object')
You want to include the index, so set index=True
. That's the default, so you can also just use df.describe().to_csv("data.csv")
.