Comments (1)
One could support this on the python side with something like:
diff --git a/py-polars/polars/datatypes/_parse.py b/py-polars/polars/datatypes/_parse.py
index 55345909c..fcbdd9376 100644
--- a/py-polars/polars/datatypes/_parse.py
+++ b/py-polars/polars/datatypes/_parse.py
@@ -37,7 +37,7 @@ else: # pragma: no cover
UnionType = UnionTypeOld
-def parse_into_dtype(input: Any) -> PolarsDataType:
+def parse_into_dtype(input: Any, *, include_unknown: bool = False) -> PolarsDataType:
"""
Parse an input into a Polars data type.
@@ -46,7 +46,7 @@ def parse_into_dtype(input: Any) -> PolarsDataType:
TypeError
If the input cannot be parsed into a Polars data type.
"""
- if is_polars_dtype(input):
+ if is_polars_dtype(input, include_unknown=include_unknown):
return input
elif isinstance(input, ForwardRef):
return _parse_forward_ref_into_dtype(input)
diff --git a/py-polars/polars/datatypes/classes.py b/py-polars/polars/datatypes/classes.py
index 08aeb53c5..68cc7be18 100644
--- a/py-polars/polars/datatypes/classes.py
+++ b/py-polars/polars/datatypes/classes.py
@@ -604,7 +604,7 @@ class List(NestedType):
inner: PolarsDataType
def __init__(self, inner: PolarsDataType | PythonDataType):
- self.inner = polars.datatypes.parse_into_dtype(inner)
+ self.inner = polars.datatypes.parse_into_dtype(inner, include_unknown=True)
def __eq__(self, other: PolarsDataType) -> bool: # type: ignore[override]
# This equality check allows comparison of type classes and type instances.
@@ -675,7 +675,7 @@ class Array(NestedType):
msg = "Array constructor is missing the required argument `shape`"
raise TypeError(msg)
- inner_parsed = polars.datatypes.parse_into_dtype(inner)
+ inner_parsed = polars.datatypes.parse_into_dtype(inner, include_unknown=True)
inner_shape = inner_parsed.shape if isinstance(inner_parsed, Array) else ()
if isinstance(shape, int):
@@ -754,7 +754,7 @@ class Field:
def __init__(self, name: str, dtype: PolarsDataType):
self.name = name
- self.dtype = polars.datatypes.parse_into_dtype(dtype)
+ self.dtype = polars.datatypes.parse_into_dtype(dtype, include_unknown=True)
def __eq__(self, other: Field) -> bool: # type: ignore[override]
return (self.name == other.name) & (self.dtype == other.dtype)
from polars.
Related Issues (20)
- Do not enclose str items in quotes in HTML repr HOT 21
- Unclear whether one should use `.describe(_optimized)_plan()` or `.explain()`
- Unable to read CSV when setting schema with a fixed tz offset
- Read Parquet Fails on ADLS for File in Subdirectory of Different Container HOT 3
- Left join large memory usage regression HOT 1
- `df.with_columns(pl.col('struct_col').shift(-1).over('group_col')` raises an error HOT 1
- Add null_values to read_json()
- Add example of `df.join(df2, how='cross')`
- [python] Support `db_kwargs` and `conn_kwargs` for ADBC connection HOT 2
- LazyFrame `collect` method, does not work when using GPU HOT 3
- str.to_titlecase() add option for capital after hyphen
- Trying to package Polars for NixOS results in an error E0599 HOT 3
- Nullability of `Struct` series HOT 3
- Unimplemented join on list[i64] succeeds with empty dataframe in lazy mode HOT 2
- More informative error messages for unsupported options in streaming mode HOT 1
- Getting a "ComputeError: cannot evaluate two Series of different lengths" with straight forward Lazy expressions. HOT 2
- release new Rust Polars version on crates.io?
- Support for handling duplicate timestamps in rolling operations similar to Pandas HOT 2
- Pandas.Timestamp timezone and unit gets modified when creating new Polars Dataframe HOT 2
- read_csv trimming white space on first line when file has no headers and is single column HOT 3
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.