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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4