-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
Closed
Labels
Milestone
Description
Specifying dropna=False drops column level names:
import pandas as pd
df = pd.DataFrame({"Col1": [23], "Col2": [45]})
names1 = pd.crosstab(df["Col1"], df["Col2"]).columns.names
names2 = pd.crosstab(df["Col1"], df["Col2"], dropna=False).columns.names
print(names1, names2)
>>>['Col2'] [None]
P.S. At first i thought dropna=False will help to count NaN values, though it seems that fillna is needed. So i don't understand, why this parameter is needed at all. If entire column is NaN then we'll get KeyError: '__dummy__' anyway.
pandas: 0.17.1