Skip to content

Commit d987dd8

Browse files
committed
add polars
1 parent 3391655 commit d987dd8

File tree

7 files changed

+38
-7
lines changed

7 files changed

+38
-7
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
.idea
1+
.idea
2+
dist
3+
uv.lock

format/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

frame/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

frame/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
# pypi `davidkhala.data.frame`
1+
# pypi `davidkhala.data.frame`
2+
3+
extras
4+
- [Pandas](https://github.com/davidkhala/py-data/wiki/Pandas)
5+
- [polars](https://github.com/davidkhala/data/blob/main/frame/polars.md)

frame/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pandas = ["pandas"]
1111
polars = ["polars"]
1212

1313
[dependency-groups]
14-
dev = ["pytest", "duckdb"]
14+
dev = ["pytest", "duckdb", "fsspec"]
1515

1616
[tool.hatch.build.targets.sdist]
1717
include = ["davidkhala"]

frame/tests/artifacts/.gitkeep

Whitespace-only changes.

frame/tests/pola_test.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import unittest
2+
from polars import DataFrame, read_csv
3+
import datetime
4+
from fsspec import filesystem
5+
class GettingStarted(unittest.TestCase):
6+
def test_rw(self):
7+
df = DataFrame(
8+
{
9+
"name": ["Alice Archer", "Ben Brown", "Chloe Cooper", "Daniel Donovan"],
10+
"birthdate": [
11+
datetime.date(1997, 1, 10),
12+
datetime.date(1985, 2, 15),
13+
datetime.date(1983, 3, 22),
14+
datetime.date(1981, 4, 30),
15+
],
16+
"weight": [57.9, 72.5, 53.6, 83.1], # (kg)
17+
"height": [1.56, 1.77, 1.65, 1.75], # (m)
18+
}
19+
)
20+
file_path = "artifacts/output.csv"
21+
filesystem('file').touch(file_path)
22+
23+
df.write_csv(file_path)
24+
df_csv = read_csv(file_path, try_parse_dates=True)
25+
print(df_csv)
26+
27+
28+
if __name__ == '__main__':
29+
unittest.main()

0 commit comments

Comments
 (0)