-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Add support of 'decimal' option to Series.to_csv and Dataframe.to_csv #8448
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0fbb0bf
to_csv: decimal support
bertrandhaut c0985ec
remove numpy directory
bertrandhaut 4261ea5
Reformating internals.py
bertrandhaut e410065
Test for to_csv decimal separator option
bertrandhaut f129b0c
Joris' comments
bertrandhaut f9a3e45
issue number as comment
bertrandhaut File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2343,7 +2343,22 @@ def test_csv_to_string(self): | |
df = DataFrame({'col' : [1,2]}) | ||
expected = ',col\n0,1\n1,2\n' | ||
self.assertEqual(df.to_csv(), expected) | ||
|
||
|
||
def test_to_csv_decimal(self): | ||
# GH 8448 | ||
df = DataFrame({'col1' : [1], 'col2' : ['a'], 'col3' : [10.1] }) | ||
|
||
expected_default = ',col1,col2,col3\n0,1,a,10.1\n' | ||
self.assertEqual(df.to_csv(), expected_default) | ||
|
||
expected_european_excel = ';col1;col2;col3\n0;1;a;10,1\n' | ||
self.assertEqual(df.to_csv(decimal=',',sep=';'), expected_european_excel) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a test for the case that also |
||
|
||
expected_float_format_default = ',col1,col2,col3\n0,1,a,10.10\n' | ||
self.assertEqual(df.to_csv(float_format = '%.2f'), expected_float_format_default) | ||
|
||
expected_float_format = ';col1;col2;col3\n0;1;a;10,10\n' | ||
self.assertEqual(df.to_csv(decimal=',',sep=';', float_format = '%.2f'), expected_float_format) | ||
|
||
class TestSeriesFormatting(tm.TestCase): | ||
_multiprocess_can_split_ = True | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
add the issue number as a comment here
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.
done
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.
I've tried to squash the commits as described but I faced the following error:
$git rebase pandas/master
fatal: Needed a single revision
invalid upstream pandas/master
Any idea ?
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.
Try this:
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.
There should be something special that I do to create my local version...
When I do the command "git checkout master" in my to level directory I get
error: pathspec 'master' did not match any file(s) known to git.
If I do it in the "pandas" directory (the one with the setup.py file) I get:
Already on 'master'
Your branch is up-to-date with 'origin/master'.
but then the second command git pull pandas/master master lead to
fatal: 'pandas/master' does not appear to be a git repository
fatal : Could not read from remote repository
By the way, in my repository, I don't think I've made any branch. I've done
everything in master. Maybe was that not a good idea ?
On Tue, Mar 3, 2015 at 9:31 AM, Stephan Hoyer [email protected]
wrote:
Bertrand Haut