Comments (5)
Oh yeah I think you're right..
from polars.
Awesome, thanks! Good lesson about aliasing a Series's name though; didn't know I could do that :)
from polars.
Yeah, it seems currently there is a hardcoded check for this potential situation:
df = pl.DataFrame({"count": ["a", "a", "b"]})
df["count"].value_counts()
# DuplicateError: using `value_counts` on a column named 'count' would lead to duplicate column names
It was recently added for GroupBy.len
due to similar issues #15222
df["count"].to_frame().group_by("*").len("occurences")
# shape: (2, 2)
# ┌───────┬────────────┐
# │ count ┆ occurences │
# │ --- ┆ --- │
# │ str ┆ u32 │
# ╞═══════╪════════════╡
# │ a ┆ 2 │
# │ b ┆ 1 │
# └───────┴────────────┘
from polars.
We do not add name
parameters to operations on a single column.
DataFrame.with_row_index
needs a name parameter because the name may clash with an existing column in the dataframe.
Series/Expr.value_counts
don't need a name parameter because you can just use alias before:
df["count"].alias("my_custom_name").value_counts()
I'll add a hint to the error message.
from polars.
Series/Expr.value_counts
don't need a name parameter because you can just use alias before:
Actually, I think we probably should add a name
param here, as we force the result name to "count". The user shouldn't have to change their column names to account for us forcing one on them 🤔 I'll make a PR with an example and you can see what you think.
from polars.
Related Issues (20)
- Update function signature of `nth` to allow positional input of indices
- `Series` constructor: 2D array to `Array` instead of `List`.
- depr: enforce `ignore_nulls` default change in 1.0 HOT 1
- Multiplying or dividing pl.duration converts to float HOT 2
- Post-join `panic` on `select` after joining on keys with different names with "coalesce=False"
- `df.group_by(series).agg(...)` fails if df was built using `pl.concat` (ShapeError) HOT 2
- `concat_list` PanicException inside `agg()` HOT 1
- A regression in numpy-to-series conversion HOT 1
- PanicException when using `collect(streaming=True)` on an empty `.parquet` file with joins.
- Regression: `.collect()` no longer generates `unexpected keywords` error. HOT 1
- Shift() fails if the argument is contained in a column HOT 1
- Support boolean iterable for argument `descending` in `DataFrame.set_sorted()`
- polars.exceptions.ComputeError: could not append value: "2024-03-05T17:39:39Z" of type: str to the builder; make sure that all rows have the same schema or consider increasing `infer_schema_length` HOT 1
- Re-aliasing existing `LazyFrame` column name does not return the last version HOT 2
- dt.truncate is 3-4x slower in polars compared to pandas HOT 3
- `.struct.with_fields` PanicException inside `agg`
- Add `show` method to `DataFrame` and `LazyFrame` HOT 1
- `gather` in `agg` context gathers values from other groups
- ShapeError: filter's length: 155 differs from that of the series: 0 HOT 9
- Version 0.20.30 bug HOT 4
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.