SparseSeries.value_counts doesn't include fill_value counts · Issue #6749 · pandas-dev/pandas (original) (raw)
Based on a suggestion from an user at stackoverflow.com, I am reporting a bug / enhancement request for sparse data frames. Please let me know if you need any more information.
Thanks in advance.
I am encountering a TypeError with a pandas sparse data frame when I use the value_counts method. I have listed the versions of the packages that I am using.
Python 2.7.6 |Anaconda 1.9.1 (x86_64)| (default, Jan 10 2014, 11:23:15)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import pandas
print pandas.version
0.13.1
import numpy
print numpy.version
1.8.0dense_df = pandas.DataFrame(numpy.zeros((10, 10))
,columns=['x%d' % ix for ix in range(10)])
dense_df['x5'] = [1.0, 0.0, 0.0, 1.0, 2.1, 3.0, 0.0, 0.0, 0.0, 0.0]
print dense_df['x5'].value_counts()
0.0 6
1.0 2
3.0 1
2.1 1
dtype: int64sparse_df = dense_df.to_sparse(fill_value=0) # Tried fill_value=0.0 also
print sparse_df.density
0.04print sparse_df['x5'].value_counts()
Traceback (most recent call last):
File "", line 1, in
File "//anaconda/lib/python2.7/site-packages/pandas/core/series.py", line 1156, in value_counts
normalize=normalize, bins=bins)
File "//anaconda/lib/python2.7/site-packages/pandas/core/algorithms.py", line 231, in value_counts
values = com._ensure_object(values)
File "generated.pyx", line 112, in pandas.algos.ensure_object (pandas/algos.c:38788)
File "generated.pyx", line 117, in pandas.algos.ensure_object (pandas/algos.c:38695)
File "//anaconda/lib/python2.7/site-packages/pandas/sparse/array.py", line 377, in astype
raise TypeError('Can only support floating point data for now')
TypeError: Can only support floating point data for now