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

Bad rendering of VersionInfo in Pandas DataFrame #87

Closed
scls19fr opened this issue May 16, 2018 · 1 comment
Closed

Bad rendering of VersionInfo in Pandas DataFrame #87

scls19fr opened this issue May 16, 2018 · 1 comment

Comments

@scls19fr
Copy link
Member

scls19fr commented May 16, 2018

Hello,

I noticed that VersionInfo are rendered badly in Pandas DataFrame.
(see scls19fr/arduino_libraries_search#8 )

They are rendered as tuple.

In [1]: import pandas as pd
In [2]: import semver
In [3]: versions = ['4.0.0', '5.0.0', '5.0.1', '10.0.0']
In [4]: df = pd.DataFrame(versions, columns=['versions'])
In [5]: df  # version as string
In [6]: df.sort_values(by='versions')  # so they are not ordered correctly
Out[6]:
  versions
3   10.0.0
0    4.0.0
1    5.0.0
2    5.0.1
In [7]: df['versions'] = df['versions'].map(semver.parse_version_info)  # parse versions as `VersionInfo`
In [8]: df.sort_values(by='versions')  # VersionInfo are ordered correctly but are badly rendered
Out[8]:
                 versions
0   (4, 0, 0, None, None)
1   (5, 0, 0, None, None)
2   (5, 0, 1, None, None)
3  (10, 0, 0, None, None)

I don't know what method Pandas use for rendering them.
What I see is that it's neither using __str__ neither using __repr__ method

In [9]: v = df['versions'].iloc[-1]

In [10]: v
Out[10]: VersionInfo(major=10, minor=0, patch=0, prerelease=None, build=None)

In [11]: v.__str__()
Out[11]: '10.0.0'

In [12]: v.__repr__()
Out[12]: 'VersionInfo(major=10, minor=0, patch=0, prerelease=None, build=None)'

VersionInfo inherits from namedtuple so this is probably related.

Any idea?

@scls19fr
Copy link
Member Author

Issue opened upstream at pandas-dev/pandas#21208

scls19fr added a commit that referenced this issue May 26, 2018
Closes #87
Closes #94
Add entries to CHANGELOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant