Skip to content

Commit a2d6651

Browse files
committed
0.0.6: add pretty
1 parent 28ff8e3 commit a2d6651

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
def md_from(df):
3+
"""
4+
markdown style
5+
"""
6+
from tabulate import tabulate
7+
return tabulate(df, headers='keys', tablefmt='github')

frame/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
[project]
22
name = "davidkhala.data.frame"
3-
version = "0.0.5"
3+
version = "0.0.6"
44
description = ""
55
authors = [{ name = "David Liu", email = "[email protected]" }]
6-
requires-python = "~=3.10"
6+
requires-python = ">=3.10"
77
readme = "README.md"
88

99
[project.optional-dependencies]
1010
pandas = ["pandas"]
1111
polars = ["polars"]
12+
pretty = ['tabulate']
1213

1314
[dependency-groups]
1415
dev = ["pytest", "duckdb", "fsspec"]

frame/tests/pretty_test.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import pandas as pd
3+
from davidkhala.data.frame.pretty import md_from
4+
data = {
5+
'Name': ['Alice', 'Bob', 'Charlie'],
6+
'Age': [25, 30, 35],
7+
'City': ['Hong Kong', 'London', 'New York']
8+
}
9+
df = pd.DataFrame(data)
10+
class TabulateTestCase(unittest.TestCase):
11+
def test_tabulate(self):
12+
from tabulate import tabulate
13+
print('psql')
14+
print(tabulate(df, headers='keys', tablefmt='psql'))
15+
print('grid')
16+
print(tabulate(df, headers='keys', tablefmt='grid'))
17+
print('fancy_grid')
18+
print(tabulate(df, headers='keys', tablefmt='fancy_grid'))
19+
print('github')
20+
print(md_from(df))
21+
22+
23+
24+
if __name__ == '__main__':
25+
unittest.main()

0 commit comments

Comments
 (0)