Skip to content

Commit

Permalink
code sample for pandas-dev#47477
Browse files Browse the repository at this point in the history
  • Loading branch information
simonjayhawkins committed Jun 25, 2022
1 parent 5dedfba commit 277a81a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions bisect/47477.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# BUG: TypeError: Int64 when using pd.pivot_table with Int64 values #47477

import pandas as pd
import io

print(pd.__version__)


data = """,country_live,employment_status,age
26983,United States,Fully employed by a company / organization,21
51776,Turkey,Working student,18
53092,India,Fully employed by a company / organization,21
44612,France,Fully employed by a company / organization,21
7043,United States,"Self-employed (a person earning income directly from one's own business, trade, or profession)",60
50421,Other country,Fully employed by a company / organization,21
2552,United Kingdom,Fully employed by a company / organization,30
21166,China,Fully employed by a company / organization,21
29144,Italy,Fully employed by a company / organization,40
36828,United States,Fully employed by a company / organization,40"""

df = pd.read_csv(io.StringIO(data))
(
df.astype({"age": "Int64"}).pivot_table(
index="country_live", columns="employment_status", values="age", aggfunc="mean"
)
)

print(df)

0 comments on commit 277a81a

Please sign in to comment.