We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here is the test code, that return the right table:
import pandas as pd data = {"C1":["A", "B", "C", "C"], "C2":["a", "a", "b", "b"], "V":[1, 2, 3, 4]} df = pd.DataFrame(data) df.pivot_table("V", index="C1", columns="C2", aggfunc="count")
when convert column to category, ValueError is raised:
df2 = df.copy() df2["C1"] = df2["C1"].astype("category") df2.pivot_table("V", index="C1", columns="C2", aggfunc="count")
groupby also raise the same error:
df2.groupby(["C1", "C2"]).count()
add dropna() to count() in groupby.py fix this problem:
dropna()
count()
groupby.py
def count(self, axis=0): return self._count().dropna().astype('int64')
The text was updated successfully, but these errors were encountered:
xref #8731
pls pd.show_versions()
pd.show_versions()
pull-requests are welcome
Sorry, something went wrong.
Here is the output of show_versions:
INSTALLED VERSIONS ------------------ commit: None python: 2.7.9.final.0 python-bits: 32 OS: Windows OS-release: 7 machine: x86 processor: x86 Family 6 Model 42 Stepping 7, GenuineIntel byteorder: little LC_ALL: None LANG: None pandas: 0.15.2.dev nose: 1.3.4 Cython: 0.21.2 numpy: 1.9.1 scipy: 0.15.0 statsmodels: 0.6.1 IPython: 3.0.0-dev sphinx: 1.2.3 patsy: 0.3.0 dateutil: 2.3 pytz: 2014.10 bottleneck: None tables: 3.1.1 numexpr: 2.4 matplotlib: 1.4.2 openpyxl: None xlrd: 0.9.3 xlwt: None xlsxwriter: 0.6.5 lxml: 3.4.1 bs4: 4.3.2 html5lib: None httplib2: None apiclient: None rpy2: 2.5.4 sqlalchemy: 0.9.8 pymysql: None psycopg2: None
1725d24
Successfully merging a pull request may close this issue.
Here is the test code, that return the right table:
when convert column to category, ValueError is raised:
groupby also raise the same error:
add
dropna()
tocount()
ingroupby.py
fix this problem:The text was updated successfully, but these errors were encountered: