Comments (4)
If you recommend casting Enums to strings when using polars.testing.assert_frame_equal, perhaps you'd consider reopening this: #16075? 😁 No fuss if not, happy to make do in the meantime since unordered enum can serve the same purpose
No, because the point I made there still stands :)
from polars.
@butterlyn for now you can just make sure to always sort your categories before creating your Enum dtype.
def sorted_enum(categories):
return pl.Enum(sorted(categories))
assert_series_equal(
pl.Series(["a"], dtype=sorted_enum(["a", "b", "c"])),
pl.Series(["a"], dtype=sorted_enum(["b", "c", "a"])), # different order
)
from polars.
If you just need this for unit tests, you can just write your own assertion util for this, e.g. cast your Enums to strings before checking equality, and then check Enum categories separately.
Still this is an important variant of categorical data that we should support.
from polars.
Thanks @stinodego, yeah I mostly need this for unit testing
If you recommend casting Enums to strings when using polars.testing.assert_frame_equal
, perhaps you'd consider reopening this: #16075? 😁 No fuss if not, happy to make do in the meantime since unordered enum can serve the same purpose
from polars.
Related Issues (20)
- Write upgrade guide for 1.0.0
- Polars is unable to parse dates beyond 2262.04.11 HOT 1
- Make a ParquetWriter context handler and/or more control over row group creation
- Casting to float32, int32, int16 and int8 in polars is slower than pandas in larger dfs HOT 4
- Interpolate based on other Float64 column HOT 3
- Comparing 0 with UInt64 values larger than Int64::MAX incorrectly return NULL
- `read_csv` ignores the `columns` parameter when reading an empty CSV file with header HOT 1
- Inconsistent XOR when using literals
- `pl.concat_str(...)`'s `ignore_nulls` arg field
- In `pl.read_csv(...)`, allow `separator=None` in order to read everything into only a single column HOT 1
- pl.DataFrame loads in 2D lists in unexpected way HOT 5
- `join_asof` breaks with certain parquet files (I think due to memory layout or something?) HOT 2
- Expressions result in different serializations across Python Polars PATCH version upgrades HOT 1
- Add inline XOR (`^`) operator for selectors HOT 3
- Inconsistency in constructing dataframes with timezone-aware datatypes HOT 8
- "Failed to determine supertype of bool and datetime[ns]" Panic
- suggest sql add `select sth` without a `from` syntax HOT 1
- Unexpected `index out of bounds` error for specific dataset and set of operations HOT 10
- `pl.DataFrame.corr()` should offer an argument "include_column_names_as_column". HOT 4
- Polars String or &str HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polars.