Skip to content

Commit 277a81a

Browse files
code sample for pandas-dev#47477
1 parent 5dedfba commit 277a81a

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

bisect/47477.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# BUG: TypeError: Int64 when using pd.pivot_table with Int64 values #47477
2+
3+
import pandas as pd
4+
import io
5+
6+
print(pd.__version__)
7+
8+
9+
data = """,country_live,employment_status,age
10+
26983,United States,Fully employed by a company / organization,21
11+
51776,Turkey,Working student,18
12+
53092,India,Fully employed by a company / organization,21
13+
44612,France,Fully employed by a company / organization,21
14+
7043,United States,"Self-employed (a person earning income directly from one's own business, trade, or profession)",60
15+
50421,Other country,Fully employed by a company / organization,21
16+
2552,United Kingdom,Fully employed by a company / organization,30
17+
21166,China,Fully employed by a company / organization,21
18+
29144,Italy,Fully employed by a company / organization,40
19+
36828,United States,Fully employed by a company / organization,40"""
20+
21+
df = pd.read_csv(io.StringIO(data))
22+
(
23+
df.astype({"age": "Int64"}).pivot_table(
24+
index="country_live", columns="employment_status", values="age", aggfunc="mean"
25+
)
26+
)
27+
28+
print(df)

0 commit comments

Comments
 (0)