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
Series not honoring class __repr__ or __str__ #18843
Comments
This is probably the same as #17695 (you inherit from dict, so your objects are iterable). It's difficult for pandas to support formatting arbitrary objects. Your simple example could be solved by not subclassing dict, and just storing your |
@TomAugspurger not subclassing from dict is not an option since the other classes are established. Is there a way to override the print function (not optimal) or set something on the class to say hey use the |
I don't believe so.
…On Tue, Dec 19, 2017 at 10:12 AM, Andrew ***@***.***> wrote:
@TomAugspurger <https://github.com/tomaugspurger> not subclassing from
dict is not an option since the other classes are established. Is there a
way to override the print function (not optimal) or set something on the
class to say hey use the __repr__
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#18843 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQHItEhFKxDvFpUMKyvOT-jdLtIstdeks5tB-BlgaJpZM4RHJWu>
.
|
In pandas/pandas/io/formats/printing.py Line 207 in cfd65e9
|
Bump to @jamesmyatt's question: why is |
Quick dirty patch for those who cannot wait for the fix:
|
@rajeee, @jamesmyatt not sure about why that check is there, a well-tested PR trying to fix this issue by removing that would be a next step here if you (or anyone else) is interested! |
This bug is no longer a bug:
But a similar issue arrises when you sub-class We could change the It does seem a lot easier to just override |
Code Sample, a copy-pastable example if possible
Problem description
For a given series with a custom object, I want to control the content when displayed via print or displaying on ipython notebooks. The object
foo
is a simple class that have the__str__
and__repr__
overwritten, but still displays the object's dictionary content, not the view I want to show the end users. How do I control that?Expected Output
alpha,beta
what I get is:
{'alpha': 'b', 'beta': 'c'}
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit: None
python: 3.5.4.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.21.1
pytest: 3.3.1
pip: 9.0.1
setuptools: 38.2.4
Cython: None
numpy: 1.11.2
scipy: 0.18.1
pyarrow: None
xarray: None
IPython: 5.3.0
sphinx: 1.6.3
patsy: 0.4.1
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 1.5.3
openpyxl: None
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 0.999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: