Skip to content

Commit e877583

Browse files
datetime seems to be interpreted correctly
1 parent 5d80083 commit e877583

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "lazylearn"
7-
version = "0.0.1"
7+
version = "0.0.2"
88
authors = [
99
{ name="Frederik P. Høngaard", email="mail@frederikhoengaard.com" },
1010
]

python/src/lazylearn/ingestion/ingestion_pipeline_steps/interpreter_step.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import numpy as np
12
import pandas as pd
23
from pandas import Series
34
from pipeline.pipeline import IngestionPipeline
@@ -33,16 +34,20 @@ def analyze_column(self, column: Series):
3334
values = column.tolist()
3435
types = [type(value) for value in values]
3536

36-
if self.categorical_test(values):
37-
return "categorical"
37+
column_type = None
3838

39+
if self.categorical_test(values):
40+
column_type = "categorical"
3941
elif self.numeric_test(types):
40-
return "numeric"
42+
column_type = "numeric"
43+
44+
if self.datetime_check(column) and not self.numeric_test(types):
45+
column_type = "datetime"
4146

42-
elif self.datetime_check(column):
43-
return "datetime"
44-
else:
45-
return "object"
47+
if column_type is None:
48+
column_type = "object"
49+
50+
return column_type
4651

4752
@staticmethod
4853
def categorical_test(values: list):
@@ -79,8 +84,10 @@ def string_test(types: set):
7984
raise NotImplementedError
8085

8186
def datetime_check(self, column: Series):
87+
if self.df[column.name].dtype.type == np.datetime64:
88+
return True
8289
try:
83-
self.df[column.name] = pd.to_datetime(column)
90+
self.df[column.name] = pd.to_datetime(self.df[column.name])
8491
return True
8592
except Exception as e: # noqa
8693
return False

python/src/lazylearn/lazylearn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def __init__(self):
77

88
def create_project(self, data, target, task="infer"):
99
# ingest data
10-
ingestion_response = Ingestion().run(data) # noqa
10+
self.dataset = Ingestion().run(data) # noqa
1111

1212
# preprocess
1313

0 commit comments

Comments
 (0)