Skip to content
New issue

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

Pivot table is making floats #3283

Closed
justinvf-zz opened this issue Apr 8, 2013 · 1 comment · Fixed by #3286

Comments

@justinvf-zz
Copy link

commented Apr 8, 2013

I am having issues with pivot table creation making columns into floats when they don't need to be.

In [313]: f = pd.DataFrame({'a' : ['cat', 'bat', 'cat', 'bat'], 'v' : [1,2,3,4], 'i' : ['a','b','a','b']})

In [314]: z = pd.pivot_table(f, values='v', rows=['a'], cols=['i'], fill_value=0, aggfunc=np.sum)

In [315]: z
Out[315]: 
i    a  b
a
bat  0  6
cat  4  0

In [316]: z.b.dtype
Out[316]: dtype('float64')

In [317]: f.v.dtype
Out[317]: dtype('int64')

In [318]: np.sum(f.v)
Out[318]: 10

In [319]: type(np.sum(f.v))
Out[319]: numpy.int64

This is making stuff ugly when I to_csv it.

@jreback

This comment has been minimized.

Copy link
Contributor

commented Apr 8, 2013

fixed in master #3286, thanks for the catch

@jreback jreback closed this Apr 8, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.