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

feat(python): minor improvement to auto-detection of ambiguous data orientation #6376

Conversation

alexander-beedie
Copy link
Collaborator

@alexander-beedie alexander-beedie commented Jan 22, 2023

Closes #6368.

Improves the likelihood of correct orient inference if that param is not explicitly supplied (at DataFrame init time) and the number of rows/cols makes the determination ambiguous.

Example / setup:

import polars as pl
pl.DataFrame( 
    data = [(1,2,"foo"),(2,3,"bar"),(3,4,"baz")], 
    columns = ["x","y","z"],
)

Before:

# shape: (3, 3)
# ┌──────┬──────┬──────┐
# │ x    ┆ y    ┆ z    │
# │ ---  ┆ ---  ┆ ---  │
# │ str  ┆ str  ┆ str  │
# ╞══════╪══════╪══════╡
# │ null ┆ null ┆ null │
# │ null ┆ null ┆ null │
# │ foo  ┆ bar  ┆ baz  │
# └──────┴──────┴──────┘

After:

# shape: (3, 3)
# ┌─────┬─────┬─────┐
# │ x   ┆ y   ┆ z   │
# │ --- ┆ --- ┆ --- │
# │ i64 ┆ i64 ┆ str │
# ╞═════╪═════╪═════╡
# │ 1   ┆ 2   ┆ foo │
# │ 2   ┆ 3   ┆ bar │
# │ 3   ┆ 4   ┆ baz │
# └─────┴─────┴─────┘

@github-actions github-actions bot added enhancement New feature or an improvement of an existing feature python Related to Python Polars labels Jan 22, 2023
@alexander-beedie
Copy link
Collaborator Author

alexander-beedie commented Jan 23, 2023

(Will resolve conflicts when I get back to my laptop later).

@alexander-beedie alexander-beedie force-pushed the improve-implicit-orientation-detection branch from 900c642 to 13805ce Compare January 23, 2023 07:15
@alexander-beedie
Copy link
Collaborator Author

@ritchie46: resolved 👍

@ritchie46 ritchie46 merged commit 418d38b into pola-rs:master Jan 23, 2023
@alexander-beedie alexander-beedie deleted the improve-implicit-orientation-detection branch January 23, 2023 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
2 participants