-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix a bug when using DataFrame.to_records with unicode column names #13462
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
Conversation
column names in python 2. (issue #11879)
tests please |
def test_to_records_with_unicode_column_names(self): | ||
# Issue #11879. to_records used to raise an exception when used | ||
# with column names containing non ascii caracters in Python 2 | ||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this being fixed by this PR? If so, remove try-except block and compare the result with the expected result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expected result is that it doesn't raise an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, you can remove try-except and compare the result with expected array. We don't use self.fail
often because any error results in failure.
can you rebase / update? |
Current coverage is 84.75% (diff: 100%)@@ master #13462 diff @@
==========================================
Files 145 145
Lines 51139 51139
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 43344 43343 -1
- Misses 7795 7796 +1
Partials 0 0
|
I've resynced my branch but it still fails. Not sure whether it is specifically due to my code though. |
can you rebase / update according to comments |
closing as stale. if you want to update, pls comment. |
Changed the way dtype is specified in to_records in order to allow unicode field names.
I changed the test as requested. Note that i corrected another problem due to the fact that numpy does not allow to specify dtype with unicode field names as list of tuples, but allows it using dictionnaries |
# with column names containing non ascii caracters in Python 2 | ||
result = DataFrame(data={u"accented_name_é": [1.0]}).to_records() | ||
# Note that numpy allows for unicode field names but dtypes need | ||
# to be specified using dictionnary intsead of list of tuples. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you have a reference for this? is it listed as a numpy bug? (if not it should be)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is referenced here:
numpy/numpy#2407
pls add a whatsnew for 0.20.0. lgtm. otherwise |
can you rebase / update |
thanks @AlexisMignon |
column names in python 2. closes pandas-dev#11879 closes pandas-dev#13462
Fix a bug when using DataFrame.to_records with unicode column names in python 2
git diff upstream/master | flake8 --diff