Im trying to get data from a parquet file using SQL syntax.
The code:
import polars as pl
# Ensure the variables are defined
parquet_file = r'C:\Users\Kperez\Documents\md_curated_20250115.parquet'
date = "2024-12-13"
df3 = pl.read_parquet(parquet_file)
# Register the DataFrame as a table and execute the SQL query
ctx = pl.SQLContext()
ctx.register("data", df3)
result = ctx.execute(f"SELECT Identifier, IQ_CLOSEPRICE FROM data where Date = '{date}'").collect()
print(result)
But I got an error like this:
NameError: name 'PyLazyFrame' is not defined
View:
Any ideas?
Im trying to get data from a parquet file using SQL syntax.
The code:
import polars as pl
# Ensure the variables are defined
parquet_file = r'C:\Users\Kperez\Documents\md_curated_20250115.parquet'
date = "2024-12-13"
df3 = pl.read_parquet(parquet_file)
# Register the DataFrame as a table and execute the SQL query
ctx = pl.SQLContext()
ctx.register("data", df3)
result = ctx.execute(f"SELECT Identifier, IQ_CLOSEPRICE FROM data where Date = '{date}'").collect()
print(result)
But I got an error like this:
NameError: name 'PyLazyFrame' is not defined
View:
Any ideas?
The problem was Python version
Polars doesn't work with Python 3.9, when I changed to Python 3.13 (latest at this moment) my code was executed successfully:
View:
The latest version of polars i.e. 1.21.0 actually supports Python 3.9 - 3.13 and has wheels for Python 3.9+ on all major platforms.
This seems to be an issue with your Windows OS and specific polars version. As was quoted in the linked issue:
This error message only appears on Windows 7 systems. It works fine on Windows 11 systems. Based on my testing, installing a version higher than 0.20.16 on Windows 7 results in this error, while installing version 0.20.16 works correctly.