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

SparseSeries error out if they're too long #11139

Closed
cyrusmaher opened this issue Sep 18, 2015 · 3 comments
Closed

SparseSeries error out if they're too long #11139

cyrusmaher opened this issue Sep 18, 2015 · 3 comments
Labels
Output-Formatting __repr__ of pandas objects, to_string Sparse Sparse Data Type

Comments

@cyrusmaher
Copy link
Contributor

Whether or not I can create a SparseSeries seems to depend on the length of the series:

pd.SparseSeries([1.] * 10) # works
pd.SparseSeries([1.] * 100) # error

I've copied the error below:

.../miniconda/lib/python2.7/site-packages/pandas/core/format.pyc in __init__(self, series, buf, length, header, na_rep, name, float_format, dtype, max_rows)

--> 148         self._chk_truncate()
    149 
    150     def _chk_truncate(self):

.../miniconda/lib/python2.7/site-packages/pandas/core/format.pyc in _chk_truncate(self)
    159             else:
    160                 row_num = max_rows // 2
--> 161                 series = concat((series.iloc[:row_num], series.iloc[-row_num:]))
    162             self.tr_row_num = row_num
    163         self.tr_series = series

.../miniconda/lib/python2.7/site-packages/pandas/tools/merge.pyc in concat(objs, axis, join, join_axes, ignore_index, keys, levels, names, verify_integrity, copy)
    752                        keys=keys, levels=levels, names=names,
    753                        verify_integrity=verify_integrity,
--> 754                        copy=copy)
    755     return op.get_result()
    756     
.../miniconda/lib/python2.7/site-packages/pandas/tools/merge.pyc in __init__(self, objs, axis, join, join_axes, keys, levels, names, ignore_index, verify_integrity, copy)
803         for obj in objs:
    804             if not isinstance(obj, NDFrame):
--> 805                 raise TypeError("cannot concatenate a non-NDFrame object")
    806 
    807             # consolidate

TypeError: cannot concatenate a non-NDFrame object
@kawochen
Copy link
Contributor

This is actually a bug in __repr__() or __str__(). If you just create the SparseSeries in a script without printing, it will work.

@kawochen
Copy link
Contributor

#10560

@jreback
Copy link
Contributor

jreback commented Sep 18, 2015

dupe of #10560

@jreback jreback closed this as completed Sep 18, 2015
@jreback jreback added Output-Formatting __repr__ of pandas objects, to_string Sparse Sparse Data Type labels Sep 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Output-Formatting __repr__ of pandas objects, to_string Sparse Sparse Data Type
Projects
None yet
Development

No branches or pull requests

3 participants