Skip to content

Commit

Permalink
docs: add polars series
Browse files Browse the repository at this point in the history
  • Loading branch information
niekdt committed Jan 27, 2025
1 parent f63e0e6 commit f600b28
Show file tree
Hide file tree
Showing 4 changed files with 598 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/actionsheets/data/python/pandas/pandas.dataframe.toml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,10 @@ code = "data.rename(str.lower, axis='columns')"
[derive.grow]
section = "Grow"

[derive.grow.col.fill]
action = "Append column _col_ with constant value _v_"
code = "?"

[derive.grow.col.append]
action = "Append column _col_ from series _s_"
code = "df.assign(col=s)"
Expand Down
29 changes: 28 additions & 1 deletion src/actionsheets/data/python/polars/polars.dataframe.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,22 @@ code = "pl.read_csv('file.csv')"
[test]
section = "Test"

[test.inherits]
action = "Is `pl.DataFrame` or subclass"
code = "isinstance(x, pl.DataFrame)"

[test.is]
action = "Is `pl.DataFrame` but not subclass"
code = "type(x) is pl.DataFrame"

[test.empty]
action = "Empty (no rows)"
code = "data.is_empty()"

[test.nempty]
action = "Not empty (has rows)"
code = "not data.is_empty()"

[test.equal]
action = "Data frames are equal"
code = "data.equals(data2)"
Expand Down Expand Up @@ -154,6 +166,10 @@ data.group_by('patient').agg(
)['dupe'].any()
"""

[test.cols.duplicates]
action = "Duplicates across two or more columns"
code = "data.select('col1', 'col2').is_duplicated().any()"

[test.col.type]
action = "Column is of type"
code = "data.schema['col1'] == dtype"
Expand All @@ -179,9 +195,13 @@ action = "Column is standard integer (64-bit)"
code = "data.schema['age'] == pl.Int64"

[test.col.type.float]
action = "Columns is float"
action = "Column is float"
code = "data.schema['age'].is_float()"

[test.col.type.date]
action = "Column is date"
code = "data.schema['date'].dtype == pl.Date"

[test.col.type.list]
action = "Column is list type"
code = "data.schema['keywords'] == pl.List"
Expand Down Expand Up @@ -682,6 +702,13 @@ data.with_columns(
"""
details = "`alias()` can be called after `pl.col()`, may be more readable sometimes"

[derive.grow.col.multi.dict.constant]
action = "Add multiple constant columns based on a dict"
code = """
for k, v in dict.items():
data = data.with_columns(pl.lit(v).alias(k))
"""


[derive.grow.int]
section = "Integer column derivations"
Expand Down
Loading

0 comments on commit f600b28

Please sign in to comment.