Comments (5)
As an alternative
pl.concat([a, a.select(pl.lit(0).alias("a"))], how='vertical_relaxed')
does what you expect.
It makes sense to me that a python int would be treated the same between the different constructors. I'm not sure if there's a reason for the difference or it is just chance. @stinodego what do you think?
from polars.
In addition, I wouldn't mind sending a patch for this. I would have, but I wanted to check first that it wasn't more complicated than it appeared. LMK
from polars.
A patch to turn the panic into a proper error is welcome!
It makes sense to me that a python int would be treated the same between the different constructors. I'm not sure if there's a reason for the difference or it is just chance. @stinodego what do you think?
There is a reason for the existing behavior, though off the top of my head I don't know why. Something to do with the difference between eager and lazy.
from polars.
PR is ready to be reviewed. Pretty simple, I didn't try to address the inconsistent int
handling.
@stinodego, if I were to guess, I bet the problem is that lazy Series can't infer a int32
without scanning it first, so it assumes int64
. Whereas lit
can trivially assume int64
, and does. I'm not sure there's an easy way to fix this without breaking backward compatibility.
from polars.
I didn't try to address the inconsistent int handling.
The lit
int handling isn't something trivial. Literals should behave different from the constructor. They are dynamic and often need to depend on the operation to define their required type. E.g. multiply a int8
column with lit(1)
should not upcast the int8
column.
If the lit
is used in isolation, we try to fit a reasonably small dtype that fits. Currently that is int32
. Smaller often leads to unexpected overflows. If the literal given doesn't fit int32
it is upcast to int64
or even uint64
if needed.
For the constructor we need to be more conservative as we don't want to inspect the whole array up front, whereas with a literal this is cheap, so we go with int64
. If you need other behavior, you need to specify your dtype.
In a future version it might be possible that we recognize the dynamic literal usage across contexts and recognized that you were concatting to a i64
, but this isn't trivial and I think also not worth the compute cost.
from polars.
Related Issues (20)
- Add a `newline` parameter to `read_csv` HOT 2
- `sort_by` + `struct` + `exclude` index out of bounds PanicException
- CSV Downloads Fail for ADLS Gen2 with Azure CLI Authentication HOT 2
- Panic on datetime column min() HOT 1
- High memory usage after `collect()` despite using `limit(1)`
- Conda package outdated HOT 1
- DateFrame.describe() reports datetime as str HOT 2
- pl.list,len() - pl.list,len() always returning u32 no matter the results HOT 1
- [FEA]: Allow specifying null location in `set_sorted`
- Expose the individual parameters from fastexcel.load_sheet in pl.read_excel HOT 1
- Provide native and fast Series slice assignment (currently slower than Pandas) HOT 6
- Supporting multidimensional array style operations, by specifying metadata columns
- struct field access returns incorrect values HOT 3
- pl.struct with no arguments triggers a panic
- Multiple expr.head(n).max()/min()/etc operations in with_columns causing ShapeError
- Add `repeat` and `tile` for Series/Expr
- `SchemaFieldNotFoundError` when chaining `select` and `collect`
- Series is ignoring the dtype argument, series.to_numpy() dtype depends on values passed
- Problem filtering categorical string columns with lazy frame and scan_parquet
- PanicException: validity must be equal to the array's length
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.