diff --git a/pyproject.toml b/pyproject.toml index 3a5256f..9e1fd81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "qsv" -version = "0.3.5" +version = "0.3.6" description = "A tool that provides elastic and rapid filtering for efficient analysis of huge CSV files, such as eventlogs." readme = "README.md" authors = [ diff --git a/src/qsv/controllers/DataFrameController.py b/src/qsv/controllers/DataFrameController.py index deae1ec..af7732e 100644 --- a/src/qsv/controllers/DataFrameController.py +++ b/src/qsv/controllers/DataFrameController.py @@ -183,11 +183,14 @@ def changetz( logger.debug(f"change {colname} timezone {timezone_from} to {timezone_to}.") self.__check_exists_colnames([colname]) - if datetime_format: - self.df = self.df.with_columns(pl.col(colname).str.to_datetime(datetime_format)) - else: - self.df = self.df.with_columns(pl.col(colname).str.to_datetime()) - + # convert string to datetime + if self.df.select(colname).collect_schema().dtypes()[0] != pl.Datetime: + if datetime_format: + self.df = self.df.with_columns(pl.col(colname).str.to_datetime(datetime_format)) + else: + self.df = self.df.with_columns(pl.col(colname).str.to_datetime()) + + # setup and change timezone self.df = self.df.with_columns(pl.col(colname).dt.replace_time_zone(timezone_from)) self.df = self.df.with_columns(pl.col(colname).dt.convert_time_zone(timezone_to)) return self diff --git a/uv.lock b/uv.lock index 4b6201e..3a214e6 100644 --- a/uv.lock +++ b/uv.lock @@ -215,7 +215,7 @@ wheels = [ [[package]] name = "qsv" -version = "0.3.2" +version = "0.3.6" source = { editable = "." } dependencies = [ { name = "fire" }, @@ -224,7 +224,7 @@ dependencies = [ { name = "rich" }, ] -[package.dependency-groups] +[package.dev-dependencies] dev = [ { name = "pdoc" }, { name = "pytest" }, @@ -238,7 +238,7 @@ requires-dist = [ { name = "rich", specifier = ">=13.9.3" }, ] -[package.metadata.dependency-groups] +[package.metadata.requires-dev] dev = [ { name = "pdoc", specifier = ">=15.0.0" }, { name = "pytest", specifier = ">=8.3.3" },