Blazingly fast DataFrame library for legacy CPUs without AVX2 support
npx @tessl/cli install tessl/pypi-polars-lts-cpu@1.33.00
# Polars-LTS-CPU
1
2
A blazingly fast DataFrame library for data manipulation and analysis, specifically compiled for legacy CPUs without AVX2 support. Built in Rust with Python bindings, polars-lts-cpu provides comprehensive DataFrame operations, lazy evaluation capabilities, SQL integration, and extensive I/O support while maintaining compatibility with older hardware that lacks modern SIMD instruction sets.
3
4
## Package Information
5
6
- **Package Name**: polars-lts-cpu
7
- **Language**: Python
8
- **Installation**: `pip install polars-lts-cpu`
9
- **Python Support**: 3.9+
10
- **License**: MIT
11
12
## Core Imports
13
14
```python
15
import polars as pl
16
```
17
18
Common patterns for specific functionality:
19
20
```python
21
# DataFrame and LazyFrame
22
from polars import DataFrame, LazyFrame
23
24
# Core functions
25
from polars import col, lit, when
26
27
# I/O operations
28
from polars import read_csv, read_parquet, scan_csv
29
30
# Data types
31
from polars import Int64, Float64, String, Boolean, Date, Datetime
32
```
33
34
## Basic Usage
35
36
```python
37
import polars as pl
38
39
# Read data from various sources
40
df = pl.read_csv("data.csv")
41
42
# Or create DataFrame from Python data
43
df = pl.DataFrame({
44
"name": ["Alice", "Bob", "Charlie"],
45
"age": [25, 30, 35],
46
"salary": [50000, 60000, 70000]
47
})
48
49
# Basic operations
50
result = (
51
df
52
.filter(pl.col("age") > 25)
53
.with_columns([
54
(pl.col("salary") * 1.1).alias("new_salary"),
55
pl.col("name").str.upper().alias("upper_name")
56
])
57
.sort("age", descending=True)
58
)
59
60
print(result)
61
62
# Lazy evaluation for better performance
63
lazy_result = (
64
df.lazy()
65
.group_by("age")
66
.agg([
67
pl.col("salary").mean().alias("avg_salary"),
68
pl.count().alias("count")
69
])
70
.collect()
71
)
72
73
print(lazy_result)
74
```
75
76
## Architecture
77
78
Polars follows a columnar memory layout with lazy evaluation:
79
80
- **DataFrame**: Eager evaluation data structure for immediate operations
81
- **LazyFrame**: Lazy evaluation with query optimization for better performance
82
- **Series**: One-dimensional data structure (column)
83
- **Expr**: Expression system for building complex transformations
84
- **I/O Layer**: Extensive support for various file formats and databases
85
- **Type System**: Rich data type system with support for complex nested structures
86
87
The design enables memory-efficient processing, streaming capabilities for large datasets, and seamless interoperability with pandas, NumPy, and PyArrow ecosystems.
88
89
## Capabilities
90
91
### Core Classes
92
93
The fundamental data structures for working with tabular data, including DataFrame for eager operations, LazyFrame for optimized query execution, Series for one-dimensional data, Expr for building complex transformations, plus configuration classes for query optimization and engine selection.
94
95
```python { .api }
96
class DataFrame:
97
def __init__(self, data=None, schema=None, **kwargs): ...
98
def select(self, *exprs): ...
99
def filter(self, predicate): ...
100
def group_by(self, *by): ...
101
def sort(self, by, *, descending=False): ...
102
103
class LazyFrame:
104
def select(self, *exprs): ...
105
def filter(self, predicate): ...
106
def collect(self, **kwargs): ...
107
def explain(self, **kwargs): ...
108
109
class Series:
110
def __init__(self, name=None, values=None, dtype=None): ...
111
def sum(self): ...
112
def mean(self): ...
113
def to_frame(self): ...
114
115
class Expr:
116
def alias(self, name): ...
117
def over(self, *partition_by): ...
118
def sum(self): ...
119
def mean(self): ...
120
121
class QueryOptFlags:
122
def __init__(self, *, predicate_pushdown=None, **kwargs): ...
123
@staticmethod
124
def none(**kwargs): ...
125
126
class GPUEngine:
127
def __init__(self): ...
128
```
129
130
[Core Classes](./core-classes.md)
131
132
### Data Types
133
134
Comprehensive type system supporting numeric, text, temporal, and complex nested data types with full type safety and memory efficiency.
135
136
```python { .api }
137
# Numeric types
138
Int8, Int16, Int32, Int64, Int128
139
UInt8, UInt16, UInt32, UInt64
140
Float32, Float64, Decimal
141
142
# Text types
143
String, Utf8, Binary
144
145
# Temporal types
146
Date, Datetime, Time, Duration
147
148
# Complex types
149
List, Array, Struct, Categorical, Enum
150
```
151
152
[Data Types](./data-types.md)
153
154
### I/O Operations
155
156
Extensive support for reading and writing data in various formats including CSV, Parquet, JSON, Arrow IPC, databases, Excel, and cloud storage with streaming capabilities.
157
158
```python { .api }
159
def read_csv(source, **kwargs): ...
160
def read_parquet(source, **kwargs): ...
161
def read_json(source, **kwargs): ...
162
def scan_csv(source, **kwargs): ...
163
def scan_parquet(source, **kwargs): ...
164
165
# Database operations
166
def read_database(query, connection, **kwargs): ...
167
def read_database_uri(query, uri, **kwargs): ...
168
```
169
170
[I/O Operations](./io-operations.md)
171
172
### Functions
173
174
Rich collection of functions for data manipulation including aggregation, lazy operations, range generation, mathematical operations, and utility functions.
175
176
```python { .api }
177
# Column selection and manipulation
178
def col(name): ...
179
def lit(value): ...
180
def when(predicate): ...
181
182
# Aggregation functions
183
def sum(*args): ...
184
def mean(*args): ...
185
def count(*args): ...
186
def max(*args): ...
187
188
# Range functions
189
def arange(start, end, step=1): ...
190
def date_range(start, end, interval): ...
191
```
192
193
[Functions](./functions.md)
194
195
### SQL Functionality
196
197
Native SQL support allowing you to query DataFrames and LazyFrames using familiar SQL syntax with full integration into the polars ecosystem.
198
199
```python { .api }
200
class SQLContext:
201
def register(self, name, frame): ...
202
def execute(self, query): ...
203
204
def sql(query, **kwargs): ...
205
```
206
207
[SQL Functionality](./sql-functionality.md)
208
209
### Configuration and Utilities
210
211
Configuration options, selectors for column operations, string caching for categorical data, and testing utilities for DataFrame comparisons.
212
213
```python { .api }
214
class Config:
215
def set_tbl_rows(self, n): ...
216
def set_tbl_cols(self, n): ...
217
218
# Selectors
219
def by_dtype(*dtypes): ...
220
def numeric(): ...
221
def string(): ...
222
223
# String cache
224
def enable_string_cache(): ...
225
226
class CompatLevel:
227
@staticmethod
228
def newest(): ...
229
@staticmethod
230
def oldest(): ...
231
```
232
233
[Configuration](./configuration.md)
234
235
### Expression Namespaces
236
237
Specialized namespaces for working with different data types including string operations (.str), datetime operations (.dt), list operations (.list), and more.
238
239
```python { .api }
240
# String operations
241
expr.str.contains(pattern)
242
expr.str.replace(pattern, replacement)
243
244
# DateTime operations
245
expr.dt.year()
246
expr.dt.strftime(format)
247
248
# List operations
249
expr.list.len()
250
expr.list.explode()
251
```
252
253
[Expression Namespaces](./expressions.md)
254
255
## Types
256
257
```python { .api }
258
# Core type definitions used across the API
259
from typing import Any, Dict, List, Optional, Union, Sequence
260
from pathlib import Path
261
262
# Common type aliases
263
ColumnNameOrSelector = Union[str, Expr, Sequence[str]]
264
IntoExpr = Union[Expr, str, int, float, bool, Sequence[Any]]
265
SchemaDict = Dict[str, type]
266
TemporalLiteral = Union[date, datetime, time, timedelta, str]
267
```