Skip to content

Pandas.DataFrame doesn't preserve the column order when converting from a DataFrames.DataFrame #72

@dimili

Description

@dimili

When converting from a DataFrames.DataFrame, the order of the columns is not preserved. Instead, the columns are sorted in alphabetical order. Is this intentional?

using DataFrames
import Pandas

df = DataFrame(C = 1:4, A = 5:8, B = 9:12)
pdf = Pandas.DataFrame(df)
print(df)
4×3 DataFrame
│ Row │ C     │ A     │ B     │
│     │ Int64 │ Int64 │ Int64 │
├─────┼───────┼───────┼───────┤
│ 1   │ 1     │ 5     │ 9     │
│ 2   │ 2     │ 6     │ 10    │
│ 3   │ 3     │ 7     │ 11    │
│ 4   │ 4     │ 8     │ 12    │
print(pdf)
   A   B  C
0  5   9  1
1  6  10  2
2  7  11  3
3  8  12  4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions