Skip to content

replace arg 'transpose' by 'wide' in to_csv and to_excel (issues 371 + 549 + 575) #576

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

alixdamman
Copy link
Collaborator

No description provided.

@alixdamman alixdamman requested a review from gdementen February 6, 2018 15:54
@gdementen
Copy link
Contributor

this is related to #371 too

Copy link
Contributor

@gdementen gdementen left a comment

Choose a reason for hiding this comment

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

Nice work. Just one thing worries me, it is the upgrade path if somebody used to_excel(transpose=True). Is it possible to somehow get the old behaviour? If so it should be mentioned how to get it in the release notes. If not, we will need to discuss this some more :)

"""
Converts LArray into Pandas Series.

Parameters
----------
name : str, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe add a changelog note about this?

replace NA values with na_rep. Defaults to ''.
wide : boolean, optional
Whether or not writing arrays in "wide" format. If True, arrays are exported with the last axis
represented horizontally. If False, arrays are exported in "narrow" format: all axes and also the values
Copy link
Contributor

Choose a reason for hiding this comment

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

"all axes and also the values are written as columns". This formulation is a bit weird => use something like "one column per axis plus one value column" instead?

@@ -234,6 +233,50 @@ Miscellaneous improvements

Closes :issue:`548`:

* replaced argument `transpose` by `wide` in `to_csv` and `to_excel` methods. The new argument `wide` has
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe split this in two separate sections:

  • to_csv(transpose -> wide), which does not need any example/explanation because it is a simple rename.
  • to_excel(transpose -> wide) which does need an explanation since the behaviour is slightly different

@alixdamman alixdamman requested a review from gdementen February 13, 2018 13:52
Copy link
Contributor

@gdementen gdementen left a comment

Choose a reason for hiding this comment

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

my previous "general comment" (not tied to particular lines) still stands.

@alixdamman alixdamman requested a review from gdementen February 13, 2018 16:00
@gdementen
Copy link
Contributor

Doh. I didn't say you needed to revert the change. I just wanted to discuss this some more. I am unsure it is worth keeping both arguments as it is likely to confuse users.

As far as I can tell, for 1D arrays, wide=False and transpose=True should give almost the same result (I think the only difference will be the name of the column), for 2D arrays, a.to_excel(transpose=True) should be equivalent to a.T.to_excel() and for >2D arrays, I don't know what transpose=True does :)

@alixdamman
Copy link
Collaborator Author

alixdamman commented Feb 15, 2018

The following file contains examples using flags wide and transpose for 1D, 2D and 3D arrays:
test_excel.xlsx

Some users may find the transpose option useful for >=3D arrays. But in that case I personally find the 'pandas' output prettier (using arr3D.to_frame().transpose().to_excel(...)) than the 'LArray' output (arr3D.to_excel(..., transpose=True))

If we keep transpose, we need to prevent users to use wide and transpose in the same time.

@gdementen
Copy link
Contributor

Thanks for this nice test file. Something like this should be in the "excel" part of the tutorial and MAYBE an abridged version should be in the changelog or at least something explaining the difference between the two arguments (not necessarily with examples)


* added argument `name` to `to_series` method allowing to set a name to the Pandas Series returned by the method:

>>> arr = ndtest((2, 3))
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if having an example is worth the space for a little used feature.

@@ -5923,8 +5969,14 @@ def to_excel(self, filepath=None, sheet_name=None, position='A1', overwrite_file
header : bool, optional
Whether or not to write a header (axes names and labels). Defaults to True.
transpose : bool, optional
Whether or not to transpose the resulting array. This can be used, for example, for writing one dimensional
arrays vertically. Defaults to False.
Whether or not to transpose the resulting array. Defaults to False.
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably needs more explanation and/or an example. Maybe also saying that for 2D, it is equivalent to arr.transpose().to_excel()

@alixdamman alixdamman requested a review from gdementen February 15, 2018 15:26
Copy link
Contributor

@gdementen gdementen left a comment

Choose a reason for hiding this comment

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

LGTM. Nice work, as usual...

@alixdamman alixdamman force-pushed the read_csv_undo_transpose_done_by_to_csv_549 branch from 3ab4818 to 090a1f8 Compare February 16, 2018 09:40
@alixdamman alixdamman changed the title replace arg 'transpose' by 'wide' in to_csv and to_excel (issues 549 + 575) replace arg 'transpose' by 'wide' in to_csv and to_excel (issues 371 + 549 + 575) Feb 16, 2018
…'transpose' of to_csv as 'wide' + added argument 'wide' to to_excel
@alixdamman alixdamman force-pushed the read_csv_undo_transpose_done_by_to_csv_549 branch from 090a1f8 to 10afd09 Compare February 16, 2018 09:45
…to set the name of the last column (i.e. the one containing the values) when exporting to csv/excel with wide=False
@alixdamman alixdamman force-pushed the read_csv_undo_transpose_done_by_to_csv_549 branch from 10afd09 to 734e095 Compare February 16, 2018 10:47
@alixdamman alixdamman merged commit 21b7b8c into larray-project:master Feb 16, 2018
@alixdamman alixdamman deleted the read_csv_undo_transpose_done_by_to_csv_549 branch February 16, 2018 11:02
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

Successfully merging this pull request may close these issues.

2 participants