Skip to content

Clarify encoding kwarg on to_csv #8857

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

Merged
merged 1 commit into from
Nov 20, 2014
Merged

Conversation

graingert
Copy link
Contributor

No description provided.

a string representing the encoding to use if the contents are
non-ascii, for python versions prior to 3
A string representing the encoding to use in the output file,
defaults to 'ascii' on Python 2 and 'utf-8' on Python 3.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this actually defaults to the sys.encoding (which has those defaults) IIRC. maybe need someone non-us to verify this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure on the semantics for Python 3, but for Python 2 the csv modules does ASCII only (or at least doesn't mention sys.encoding at all), not sure if we've changed the defaults internally.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default encoding is indeed ascii for py2 and utf-8 for py3. There is a way to change that but it involves quite a bit of magic: http://stackoverflow.com/questions/2276200/changing-default-encoding-of-python

@jreback jreback added Docs Unicode Unicode strings IO CSV read_csv, to_csv labels Nov 19, 2014
@jreback jreback added this to the 0.15.2 milestone Nov 19, 2014
jreback added a commit that referenced this pull request Nov 20, 2014
Clarify encoding kwarg on to_csv
@jreback jreback merged commit f010229 into pandas-dev:master Nov 20, 2014
@jreback
Copy link
Contributor

jreback commented Nov 20, 2014

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs IO CSV read_csv, to_csv Unicode Unicode strings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants