Skip to content

BUG: iloc on DataFrame[ea] #32957

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

Closed
jbrockmendel opened this issue Mar 23, 2020 · 3 comments · Fixed by #32959
Closed

BUG: iloc on DataFrame[ea] #32957

jbrockmendel opened this issue Mar 23, 2020 · 3 comments · Fixed by #32959
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Mar 23, 2020

from pandas.tests.extension.decimal.test_decimal import *
arr = data.__wrapped__()
ser = pd.Series(arr)
df = pd.DataFrame({"a": ser})

>>> df.iloc[:, :1]
                                                   a
0  Decimal: 0.32737812402736643502265678762341849...
1                                                   
2                                                   
3                                                   

>>> df.iloc[:, :1].values
array([[Decimal('0.32737812402736643502265678762341849505901336669921875')]],
      dtype=object)

Maybe slicing on the wrong axis?

@jorisvandenbossche
Copy link
Member

I actually get an error:

In [2]: df.iloc[:, :1]                                                                                                                                                                                             
Out[2]: ---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
~/miniconda3/envs/dev/lib/python3.7/site-packages/IPython/core/formatters.py in __call__(self, obj)
    700                 type_pprinters=self.type_printers,
    701                 deferred_pprinters=self.deferred_printers)
--> 702             printer.pretty(obj)
    703             printer.flush()
    704             return stream.getvalue()

~/miniconda3/envs/dev/lib/python3.7/site-packages/IPython/lib/pretty.py in pretty(self, obj)
    400                         if cls is not object \
    401                                 and callable(cls.__dict__.get('__repr__')):
--> 402                             return _repr_pprint(obj, self, cycle)
    403 
    404             return _default_pprint(obj, self, cycle)

~/miniconda3/envs/dev/lib/python3.7/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
    695     """A pprint that just redirects to the normal repr function."""
    696     # Find newlines and replace them with p.break_()
--> 697     output = repr(obj)
    698     for idx,output_line in enumerate(output.splitlines()):
    699         if idx:

~/scipy/pandas/pandas/core/frame.py in __repr__(self)
    695             line_width=width,
    696             max_colwidth=max_colwidth,
--> 697             show_dimensions=show_dimensions,
    698         )
    699 

~/scipy/pandas/pandas/core/frame.py in to_string(self, buf, columns, col_space, header, index, na_rep, formatters, float_format, sparsify, index_names, justify, max_rows, min_rows, max_cols, show_dimensions, decimal, line_width, max_colwidth, encoding)
    827                 line_width=line_width,
    828             )
--> 829             return formatter.to_string(buf=buf, encoding=encoding)
    830 
    831     # ----------------------------------------------------------------------

~/scipy/pandas/pandas/io/formats/format.py in to_string(self, buf, encoding)
    901         encoding: Optional[str] = None,
    902     ) -> Optional[str]:
--> 903         return self.get_result(buf=buf, encoding=encoding)
    904 
    905     def to_latex(

~/scipy/pandas/pandas/io/formats/format.py in get_result(self, buf, encoding)
    518         """
    519         with self.get_buffer(buf, encoding=encoding) as f:
--> 520             self.write_result(buf=f)
    521             if buf is None:
    522                 return f.getvalue()

~/scipy/pandas/pandas/io/formats/format.py in write_result(self, buf)
    814         else:
    815 
--> 816             strcols = self._to_str_columns()
    817             if self.line_width is None:  # no need to wrap around just print
    818                 # the whole frame

~/scipy/pandas/pandas/io/formats/format.py in _to_str_columns(self)
    777             for ix, col in enumerate(strcols):
    778                 # infer from above row
--> 779                 cwidth = self.adj.len(strcols[ix][row_num])
    780                 is_dot_col = False
    781                 if truncate_h:

IndexError: list index out of range

@jorisvandenbossche
Copy link
Member

Ah, that's in the repr. Stil strange that you don't get an error in the repr

@jbrockmendel
Copy link
Member Author

Stil strange that you don't get an error in the repr

Yah, I actually get the same behavior you're getting now, but didnt 18 hours ago. No idea what changed

@jreback jreback added Bug ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves labels Mar 26, 2020
@jreback jreback added this to the 1.1 milestone Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays. Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants