Icon

kn_​example_​python_​polars_​pandas_​arrow

working with Polars dataframe in KNIME Python node

working with Polars dataframe in KNIME Python node

working with Polars dataframe in KNIME Python node import knime.scripting.io as knioimport pandas as pdimport numpy as npimport polars as pl# https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.from_arrow.html# https://pola-rs.github.io/polars/py-polars/html/reference/dataframe/api/polars.DataFrame.to_arrow.htmlarr_df = knio.input_tables[0]print(type(arr_df))# arr_df = knio.input_tables[0]# print(type(arr_df))# df1 = pl.from_arrow(arr_df)pd_df = knio.input_tables[0].to_pandas()pl_df = pl.from_pandas(pd_df)print(type(pl_df))pd_df2 = pl_df.to_pandas()arr_df2 = pl_df.to_arrow()print(type(arr_df2))knio.output_tables[0] = knio.Table.from_pandas(pd_df2)knio.output_tables[1] = arr_df test_data_all_typesNode 267py39_knime_polars.ymlKNIME and Python — Setting up and managing Conda environmentshttps://medium.com/p/2ac217792539test dataNode 273 Test Data Generator prepare_data Column Resorter Python Script Conda EnvironmentPropagation Data Generator Column Filter working with Polars dataframe in KNIME Python node import knime.scripting.io as knioimport pandas as pdimport numpy as npimport polars as pl# https://pola-rs.github.io/polars/py-polars/html/reference/api/polars.from_arrow.html# https://pola-rs.github.io/polars/py-polars/html/reference/dataframe/api/polars.DataFrame.to_arrow.htmlarr_df = knio.input_tables[0]print(type(arr_df))# arr_df = knio.input_tables[0]# print(type(arr_df))# df1 = pl.from_arrow(arr_df)pd_df = knio.input_tables[0].to_pandas()pl_df = pl.from_pandas(pd_df)print(type(pl_df))pd_df2 = pl_df.to_pandas()arr_df2 = pl_df.to_arrow()print(type(arr_df2))knio.output_tables[0] = knio.Table.from_pandas(pd_df2)knio.output_tables[1] = arr_df test_data_all_typesNode 267py39_knime_polars.ymlKNIME and Python — Setting up and managing Conda environmentshttps://medium.com/p/2ac217792539test dataNode 273Test Data Generator prepare_data Column Resorter Python Script Conda EnvironmentPropagation Data Generator Column Filter

Nodes

Extensions

Links