-
Notifications
You must be signed in to change notification settings - Fork 87
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
UnicodeEncodeError when trying pivot_ui(df) #2
Comments
OK, I'll see if I can fix this :) Can you provide a sample data frame that causes this problem? |
I'm having trouble replicating this problem... Can you provide a bit more context/sample code please? What versions of Jupyter/Pandas/Python are you using? |
Sorry for the long delay on this, but I'm back to giving this project a bit of love... Can someone post a link to a CSV file that exposes this problem? I still can't replicate it. |
This reproduces the error:
You should probably treat the input things and template as unicode, and then properly encode it for writing. Easy to fix:
This fixes it for py3.6, and should work for 2.7 too (not tested). |
I'm actually seeing the same behaviour in Python 3.5 |
The problem is that you do things without ever specifying an encoding, so behaviour is system dependent.
You should always specify the encoding you wish to use for text IO, even if it happens to work at the time on your dev environment. |
Also a cleaner way than my fix would be to just use |
Ok I'll look into that, thanks!
To your earlier point, which is the specific call am I making that has
system-dependent behaviour if encoding is not specified?
…On Wed, May 10, 2017 at 16:36 indivisible ***@***.***> wrote:
Also a cleaner way than my fix would be to just use io.open(outfile_path,
'w', encoding='utf8') to open the file.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMbA5L0_5RbCbDawr-0ZwhQeqf93Vndks5r4h-zgaJpZM4F8jQ5>
.
|
Ah never mind, I see the link now :)
…On Wed, May 10, 2017 at 17:51 Nicolas Kruchten ***@***.***> wrote:
Ok I'll look into that, thanks!
To your earlier point, which is the specific call am I making that has
system-dependent behaviour if encoding is not specified?
On Wed, May 10, 2017 at 16:36 indivisible ***@***.***>
wrote:
> Also a cleaner way than my fix would be to just use io.open(outfile_path,
> 'w', encoding='utf8') to open the file.
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <#2 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AAMbA5L0_5RbCbDawr-0ZwhQeqf93Vndks5r4h-zgaJpZM4F8jQ5>
> .
>
|
@indivisible your suggestion does work in Python 3 but causes all sorts of encoding errors in Python 2.7 for me with the following CSV: https://github.com/nicolaskruchten/pivottable/blob/master/examples/mps.csv |
I see, sorry. I finally installed python2.7 and looked a bit closer at the problem. I've made a gist that has a script to reproduce the problem, sample outputs, and a slightly better patch. |
OK, nice, this seems like a reasonably elegant fix @indivisible, thanks! Question re your gist: in |
Without. With the patch applied all outputs matched. I have no idea how locale settings on Macs work, the only systems I could test it on were Linux and Windows. The sample output is from Linux. On windows the "preferred encoding" seems to be cp1252... Cheers! |
Awesome, thanks so much for the help! I've just released v0.7.0 with these fixes :) |
Great tool for data exploration, I think this should be a core utility of Jupyter!
I got the error message:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 8-11: ordinal not in range(128)
I think it is because of of the pd.to_csv method, adding some encoding handling capability could fix this.
But not really sure how...
thank you for the great js magic!
The text was updated successfully, but these errors were encountered: