Skip to content

Commit

Permalink
fix: deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
makkus committed Dec 3, 2024
1 parent a2cde56 commit be8eb17
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions src/kiara_plugin/tabular/models/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from kiara.models import KiaraModel
from kiara.models.values.value import Value
from kiara.models.values.value_metadata import ValueMetadata
from kiara.utils import log_exception
from kiara_plugin.tabular.models import TableMetadata
from kiara_plugin.tabular.utils.tables import extract_column_metadata

Expand All @@ -34,6 +35,7 @@ class KiaraTable(KiaraModel):
def create_table(cls, data: Any) -> "KiaraTable":
"""Create a `KiaraTable` instance from an Apache Arrow Table, or dict of lists."""

import pandas as pd
import polars as pl

if isinstance(data, KiaraTable):
Expand All @@ -50,11 +52,20 @@ def create_table(cls, data: Any) -> "KiaraTable":
table_obj = data
elif isinstance(data, (pl.DataFrame)):
table_obj = data.to_arrow()
elif isinstance(data, (pd.DataFrame)):
try:
table_obj = pa.table(data)
except Exception as e:
log_exception(e)
raise Exception(f"Can't create table from pandas dataframe: {e}")
else:
try:
table_obj = pa.table(data)
except Exception:
pass
except Exception as e:
log_exception(e)
raise Exception(
f"Can't create table, invalid source data type: {type(data)}."
)

if table_obj is None:
if isinstance(data, (str)):
Expand Down
5 changes: 4 additions & 1 deletion src/kiara_plugin/tabular/modules/array/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ def parse_date(_text: str):

series = pl.Series(name="tokens", values=array.arrow_array)
job_log.add_log(f"start parsing date for {len(array)} items")
result = series.apply(parse_date)
# result = series.apply(parse_date)

result = series.map_elements(parse_date, return_dtype=pl.Date)

job_log.add_log(f"finished parsing date for {len(array)} items")
result_array = result.to_arrow()

Expand Down

0 comments on commit be8eb17

Please sign in to comment.