Skip to content
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

Fix for scrambled order of columns #73

Merged
merged 1 commit into from
Aug 28, 2021
Merged

Conversation

PallHaraldsson
Copy link
Contributor

@PallHaraldsson PallHaraldsson commented Sep 24, 2020

Fixes: #72

@PallHaraldsson
Copy link
Contributor Author

Hi, @AStupidBear a fix here I think. I copied latter commit from another package, it was slightly different with: DataStructures = "0.17, 0.18"

Project.toml Outdated Show resolved Hide resolved
@PallHaraldsson PallHaraldsson changed the title RFC: Fix for scrambled order of columns Fix for scrambled order of columns Sep 28, 2020
@PallHaraldsson
Copy link
Contributor Author

Just merge this? I'm pretty sure this works. My "but is there a better way?" RFC was about efficiency, while not too important here.

@tkf
Copy link
Member

tkf commented Sep 28, 2020

I think it's better to wait for @malmaud (although technically I can hit the merge button).

Until then, I think adding a test would help to smooth the review. Maybe test that the order of columns is preserved with the data frames with columns (say) a, b, c and c, b, a?

Also, since Pandas.jl needs PyCall.jl anyway, I guess we can use PyDict to avoid relying on OrderedCollections.jl here just for one line? Alternatively, it also should be possible to add a column to pandas.DataFrame one-by-one.

@PallHaraldsson
Copy link
Contributor Author

If I get my way and Dict will be OrderedDict in Base, then this wouldn't be needed, as of next Julia LTS. But the dependency is light, and may even end up as a stdlib, so I wouldn't worry about that part.

About a test: OrderedDict means the order couldn't be different.

@malmaud
Copy link
Collaborator

malmaud commented Sep 29, 2020

Thanks! I agree with @tkf - this needs a test and I'd rather avoid adding a dependency.

@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Sep 29, 2020

I did try to avoid this cheap dependency. I probably spent way more time on that (and also the rest) than I have time for now, but couldn't see a good way. It's at least very simple this way, and I'm already using it by using my own fork, since not merged here. My priority now, is well my job, and I already made the PR to JuliaLang to make OrderedDict the default, but it may need followup/convincing people, as I want it in Julia 1.6 but if wouldn't help here for users on older versions.

@malmaud malmaud force-pushed the patch-1 branch 2 times, most recently from 9a071e9 to 18ebf3f Compare August 28, 2021 18:56
Co-authored-by: Páll Haraldsson <Pall.Haraldsson@gmail.com>
@codecov-commenter
Copy link

codecov-commenter commented Aug 28, 2021

Codecov Report

❗ No coverage uploaded for pull request base (main@bf5ddfd). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main      #73   +/-   ##
=======================================
  Coverage        ?   66.00%           
=======================================
  Files           ?        5           
  Lines           ?      253           
  Branches        ?        0           
=======================================
  Hits            ?      167           
  Misses          ?       86           
  Partials        ?        0           
Flag Coverage Δ
unittests 66.00% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf5ddfd...6910720. Read the comment docs.

@malmaud
Copy link
Collaborator

malmaud commented Aug 28, 2021

Thanks Pall, I just added a test and will merge this now.

@malmaud malmaud merged commit 97c4602 into JuliaPy:main Aug 28, 2021
@PallHaraldsson PallHaraldsson deleted the patch-1 branch August 29, 2021 22:13
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.

Pandas.DataFrame doesn't preserve the column order when converting from a DataFrames.DataFrame
4 participants