diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5cf9255..ef79bd6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## [0.0.4] - 2026-06-25
+- Avoid RangeIndex beeing modified in modifiy_timezone
+- Enhance documentation of modify_timezone
+
## [0.0.3] - 2026-06-23
- Fixes in modifiy_timezone
- Disarm dependencies to ease compatibility to designer development
diff --git a/docs/index.html b/docs/index.html
index fb8af20..ad4989a 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -600,7 +600,10 @@
Functions
Converts time information of pandas objects to a certain timezone
-This function is applicable to index and/or columns of pd.Series or pd.DataFrame as well as for single pd.Timestamp objects.
+This function is applicable to index and/or columns of pd.Series or pd.DataFrame as well as for single pd.Timestamp objects.
+If time zone information is not defined in object to convert it is assumed that it is in UTC.
+Please note that column_names and convert_index are not exclusive to enable modifying both at the same time.
+To enable modifying the value of a series (not the index), please name the series and define the series’ name in column_names.
- Parameters:
diff --git a/docs/searchindex.js b/docs/searchindex.js
index 7ee22af..11f5f46 100644
--- a/docs/searchindex.js
+++ b/docs/searchindex.js
@@ -1 +1 @@
-Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","modify_timezone"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"05t13":1,"06t13":1,"5s":0,"A":1,"All":0,"As":[],"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"Then":[],"This":[0,1],"To":0,"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"add_config_set":[],"adequ":1,"adit":1,"adjust":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"attr":1,"autoexpand":[],"avail":1,"awar":0,"axes_label_color":[],"axi":0,"b":[],"background":[],"background_color":0,"bar":[],"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"by_metr":1,"c":1,"call":[],"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"circl":[],"class":1,"cm":0,"code":[0,1],"collect":1,"color":0,"colorway":[],"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correct":[],"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"datetime_tick_format":[],"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"deprec":[],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"displaylogo":[],"displaymodebar":[],"doe":0,"e":1,"eas":1,"edg":0,"edit":0,"empti":1,"end":[0,1],"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"ever":[],"exampl":[0,1],"expect":1,"explan":[],"explicit":0,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fals":[],"fig":0,"figur":0,"find":[],"first":1,"fit":[],"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":0,"goal":0,"graph_object":0,"grid":[],"grid_color":[],"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"hide_legend":[],"hide_x_titl":[],"higher":[],"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"info":1,"info_color":0,"inform":0,"input":0,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":0,"keep":0,"key":1,"kwarg":1,"l":[],"label":0,"last":[],"layout":[],"leav":[],"legend":[],"let":[0,1],"level":0,"like":[0,1],"limit":0,"line":0,"line_color":[],"list":1,"local":[],"logo":[],"look":0,"m":1,"magnitud":0,"main":0,"make":0,"margin":[],"marker":0,"marker_symbol":[],"match":[],"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"minim":[],"miss":0,"mode":[],"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"modifyng":[],"mtsf":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"necessari":[],"next":[],"none":1,"normal":[],"note":[0,1],"now":[],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"order":0,"otherwis":0,"output":1,"packag":1,"pad":[],"panda":1,"paper":[],"paper_bgcolor":[],"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":[],"platform":1,"plot":1,"plot_bgcolor":[],"plot_target_local":[],"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"prioriti":[],"properti":0,"provid":[0,1],"provis":0,"purpos":0,"pytz":1,"queri":1,"r":[],"rais":1,"rang":0,"rare":[],"re":1,"reason":0,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"remov":[],"remove_plotly_bar":[],"remove_plotly_icon":[],"repres":0,"request":[0,1],"result":1,"retriev":[0,1],"return":[0,1],"rgba":[],"ruhr":1,"run":[],"s":[0,1],"said":[],"say":0,"scatter":0,"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"showlegend":[],"simple_whit":[],"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"size":[],"soon":[],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"t":[],"tbd":1,"temp":1,"temperatur":1,"templat":[],"test":1,"tickformat":[],"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"title_standoff":[],"title_text":[],"to_datetim":1,"to_timezon":1,"toggleabl":1,"total_second":1,"trace":[],"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"unless":[],"updat":[],"update_layout":0,"update_x_axes_tickformat":[],"update_xax":0,"use":1,"use_default_standoff":[],"use_minimum_margin":[],"use_muplot_axes_color":[],"use_muplot_grid":[],"use_muplot_line_and_mark":[],"use_platform_background":[],"use_platform_colorway":[],"use_platform_default":[],"use_simple_white_templ":[],"utc":0,"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"visibl":[],"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"width":[],"will":0,"without":[],"write":1,"wwe":[],"x":0,"xax":[],"y":0,"yax":[],"yaxis_titl":0,"\u00b5plot":[]},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"except":1,"explan":0,"first":0,"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}})
\ No newline at end of file
+Search.setIndex({"alltitles":{"Explanation":[[0,"explanation"]],"First steps":[[0,null]],"Functions":[[1,"functions"]],"Further Information":[[1,"further-information"]],"How to get metadata with hdhelpers?":[[0,"how-to-get-metadata-with-hdhelpers"]],"How to use hdhelpers for plotting? (tbd)":[[0,"how-to-use-hdhelpers-for-plotting-tbd"]],"Introduction":[[1,"introduction"]],"exceptions":[[1,"module-hdhelpers.exceptions"]],"hdhelpers":[[1,null]],"helpers":[[1,"module-hdhelpers.helpers"]],"metadata":[[1,"module-hdhelpers.metadata"]]},"docnames":["first_steps","index"],"envversion":{"sphinx":66,"sphinx.domains.c":3,"sphinx.domains.changeset":1,"sphinx.domains.citation":1,"sphinx.domains.cpp":9,"sphinx.domains.index":1,"sphinx.domains.javascript":3,"sphinx.domains.math":2,"sphinx.domains.python":4,"sphinx.domains.rst":2,"sphinx.domains.std":2},"filenames":["first_steps.rst","index.rst"],"indexentries":{},"objects":{"hdhelpers":[[1,0,0,"-","exceptions"],[1,0,0,"-","helpers"],[1,0,0,"-","metadata"]],"hdhelpers.exceptions":[[1,1,1,"","HelperException"],[1,1,1,"","InsufficientPlottingData"]],"hdhelpers.helpers":[[1,2,1,"","modify_timezone"]],"hdhelpers.metadata":[[1,2,1,"","get_display_names"],[1,2,1,"","get_measurements"],[1,2,1,"","get_metric_info"],[1,2,1,"","get_names"],[1,2,1,"","get_queried_interval"],[1,2,1,"","get_series_display_name"],[1,2,1,"","get_series_info"],[1,2,1,"","get_series_measurement"],[1,2,1,"","get_series_name"],[1,2,1,"","get_series_short_display_name"],[1,2,1,"","get_series_unit"],[1,2,1,"","get_short_display_names"],[1,2,1,"","get_units"]]},"objnames":{"0":["py","module","Python module"],"1":["py","exception","Python exception"],"2":["py","function","Python function"]},"objtypes":{"0":"py:module","1":"py:exception","2":"py:function"},"terms":{"000z":0,"00z":1,"01t01":1,"01t08":0,"05t13":1,"06t13":1,"5s":0,"A":1,"All":0,"As":[],"DO":0,"For":[0,1],"How":1,"If":1,"In":[0,1],"It":[0,1],"NOT":0,"Our":0,"That":0,"The":0,"Then":[],"This":[0,1],"To":[0,1],"We":0,"With":0,"__data__":0,"__hd_wrapped_data_object__":0,"__metadata__":0,"abov":0,"abstract":1,"access":1,"accord":0,"activ":0,"add_config_set":[],"adequ":1,"adit":1,"adjust":1,"all_timezon":1,"allow":1,"also":0,"ani":[0,1],"anoth":1,"appli":0,"applic":1,"arbitrari":1,"arg":1,"associ":1,"assum":1,"attr":1,"autoexpand":[],"avail":1,"awar":0,"axes_label_color":[],"axi":0,"b":[],"background":[],"background_color":0,"bar":[],"base":1,"becaus":0,"behaviour":[0,1],"berlin":1,"bool":1,"boolean":1,"by_metr":1,"c":1,"call":[],"can":[0,1],"case":[0,1],"certain":1,"chosen":0,"circl":[],"class":1,"cm":0,"code":[0,1],"collect":1,"color":0,"colorway":[],"column":1,"column_nam":1,"communic":0,"compli":1,"compon":[0,1],"concret":1,"configur":0,"contain":[0,1],"context":[0,1],"contrast":1,"control":[0,1],"convent":1,"convert":[0,1],"convert_index":1,"convey":0,"correct":[],"correspond":[0,1],"current":0,"custom":1,"cut":0,"danger":0,"data":[0,1],"datafram":1,"dataset_metadata":1,"date":1,"datetim":1,"datetime_tick_format":[],"def":0,"default":[0,1],"default_titl":0,"default_unit":0,"defaultdict":1,"defin":[0,1],"deprec":[],"design":[0,1],"detail":0,"determin":0,"dict":[0,1],"dictionari":1,"dimens":1,"direct":0,"display":1,"display_nam":1,"display_name_of_metric1":1,"display_name_of_seri":1,"displaylogo":[],"displaymodebar":[],"doe":0,"e":1,"eas":1,"edg":0,"edit":0,"empti":1,"enabl":1,"end":[0,1],"entri":1,"entrypoint":0,"equival":1,"error":1,"error_cod":1,"error_color":0,"especi":1,"europ":1,"ever":[],"exampl":[0,1],"exclus":1,"expect":1,"explan":[],"explicit":0,"external_first":1,"external_id":1,"external_second":1,"extra_inform":1,"extract":1,"fals":[],"fig":0,"figur":0,"find":[],"first":1,"fit":[],"flag":0,"follow":[0,1],"format":1,"four":0,"frontend":1,"full_titl":0,"function":0,"g":1,"generat":1,"german":1,"get":1,"get_and_pad_start_and_end_timestamp":0,"get_colors_from_plot_target_set":0,"get_display_nam":1,"get_measur":1,"get_metric_info":1,"get_nam":1,"get_queried_interv":1,"get_series_display_nam":1,"get_series_info":1,"get_series_measur":1,"get_series_nam":[0,1],"get_series_short_display_nam":1,"get_series_unit":[0,1],"get_short_display_nam":1,"get_unit":1,"get_value_dimension_info":1,"get_y_axis_label":0,"given":1,"global":[0,1],"glom":1,"go":0,"goal":0,"graph_object":0,"grid":[],"grid_color":[],"half":0,"handl":1,"happen":1,"hardwir":0,"helper":0,"helperexcept":1,"hetida":[0,1],"hide":0,"hide_legend":[],"hide_x_titl":[],"higher":[],"id":1,"import":[0,1],"includ":[0,1],"index":[0,1],"info":1,"info_color":0,"inform":0,"input":0,"instal":1,"instead":1,"insuffici":1,"insufficientplottingdata":1,"int":1,"integr":1,"intend":0,"interpret":1,"interv":[0,1],"iso":1,"isoformat":1,"json":[0,1],"just":0,"keep":0,"key":1,"kwarg":1,"l":[],"label":0,"last":[],"layout":[],"leav":[],"legend":[],"let":[0,1],"level":0,"like":[0,1],"limit":0,"line":0,"line_color":[],"list":1,"local":[],"logo":[],"look":0,"m":1,"magnitud":0,"main":0,"make":0,"margin":[],"marker":0,"marker_symbol":[],"match":[],"meaning":1,"measur":1,"mention":0,"messag":[0,1],"method":1,"metric":[0,1],"metric1":1,"metric2":1,"metric3":1,"metric_info":1,"metric_key":1,"might":0,"minim":[],"miss":0,"mode":[],"modifi":1,"modified_timezon":1,"modify_timezon":[0,1],"modifyng":[],"mtsf":1,"multitsfram":1,"naiv":0,"name":[0,1],"name_of_metric1":1,"name_of_metric2":1,"name_of_series_1":1,"name_of_series_2":1,"necessari":[],"next":[],"none":1,"normal":[],"note":[0,1],"now":[],"object":[0,1],"object_to_convert":1,"one":1,"onli":1,"oper":1,"option":[0,1],"order":0,"otherwis":0,"output":1,"packag":1,"pad":[],"panda":1,"paper":[],"paper_bgcolor":[],"paramet":[0,1],"pars":0,"pass":0,"pd":1,"place":[],"platform":1,"pleas":1,"plot":1,"plot_bgcolor":[],"plot_target_local":[],"plot_target_set":[0,1],"plot_target_styl":0,"plot_target_timezon":0,"plotly_fig_to_json_dict":0,"point":0,"possibl":[0,1],"potenti":0,"precis":0,"present":1,"prioriti":[],"properti":0,"provid":[0,1],"provis":0,"purpos":0,"pytz":1,"queri":1,"r":[],"rais":1,"rang":0,"rare":[],"re":1,"reason":0,"ref_interval_end_timestamp":[0,1],"ref_interval_start_timestamp":[0,1],"reflect":0,"remov":[],"remove_plotly_bar":[],"remove_plotly_icon":[],"repres":0,"request":[0,1],"result":1,"retriev":[0,1],"return":[0,1],"rgba":[],"ruhr":1,"run":[],"s":[0,1],"said":[],"say":0,"scatter":0,"scheme":1,"second":1,"see":[0,1],"sensibl":1,"seri":[0,1],"serial":[0,1],"set":[0,1],"short":1,"short_display_nam":[0,1],"short_display_name_of_metric1":1,"short_display_name_of_seri":1,"show":1,"showlegend":[],"simple_whit":[],"sinc":[0,1],"singl":1,"single_metric_dataset_metadata":0,"single_metric_metadata":[0,1],"size":[],"soon":[],"spec":1,"specif":0,"specifi":1,"standard":[0,1],"start":[0,1],"start_pad":0,"status":0,"status_color":0,"step":1,"str":1,"streamlin":1,"string":1,"structured_metadata":[0,1],"style":[0,1],"success_color":0,"sure":0,"surpress":1,"t":[],"tbd":1,"temp":1,"temperatur":1,"templat":[],"test":1,"tickformat":[],"time":[0,1],"timeseri":[0,1],"timestamp":[0,1],"timezon":[0,1],"titl":0,"title_standoff":[],"title_text":[],"to_datetim":1,"to_timezon":1,"toggleabl":1,"total_second":1,"trace":[],"transform":1,"tri":1,"true":1,"tupl":1,"turn":0,"type":1,"typeerror":1,"tz_convert":1,"underlying":1,"unit":[0,1],"unless":[],"updat":[],"update_layout":0,"update_x_axes_tickformat":[],"update_xax":0,"use":1,"use_default_standoff":[],"use_minimum_margin":[],"use_muplot_axes_color":[],"use_muplot_grid":[],"use_muplot_line_and_mark":[],"use_platform_background":[],"use_platform_colorway":[],"use_platform_default":[],"use_simple_white_templ":[],"utc":[0,1],"utcoffset":1,"valu":[0,1],"value_dim_1":1,"value_dim_info":1,"value_dimens":1,"value_name_of_seri":1,"valueerror":1,"vari":1,"variabl":[0,1],"via":1,"visibl":[],"want":0,"warn_color":0,"water":0,"way":[0,1],"well":1,"whether":1,"width":[],"will":0,"without":[],"write":1,"wwe":[],"x":0,"xax":[],"y":0,"yax":[],"yaxis_titl":0,"zone":1,"\u00b5plot":[]},"titles":["First steps","hdhelpers"],"titleterms":{"Further":1,"How":0,"except":1,"explan":0,"first":0,"function":1,"get":0,"hdhelper":[0,1],"helper":1,"inform":1,"introduct":1,"metadata":[0,1],"plot":0,"step":0,"tbd":0,"use":0}})
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index ce5e6a4..420c0ce 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -20,7 +20,7 @@ exclude = [
[project]
name = "hdhelpers"
-version = "0.0.3"
+version = "0.0.4"
description = "Streamlines metadata & timezone handling, and plotting in hetida designer components"
readme = "README.md"
maintainers = [
diff --git a/src/hdhelpers/__init__.py b/src/hdhelpers/__init__.py
index 7e1b713..2204863 100644
--- a/src/hdhelpers/__init__.py
+++ b/src/hdhelpers/__init__.py
@@ -5,7 +5,7 @@
from .plot_target_settings import StatusColors
# do not edit line of __version__ as it is automatically modified by running ./run build_package
-__version__ = "0.0.3"
+__version__ = "0.0.4"
# function can be automated with from hdhelpers import *
__all__ = [
diff --git a/src/hdhelpers/helpers/timezone_handling.py b/src/hdhelpers/helpers/timezone_handling.py
index 003213b..4958313 100644
--- a/src/hdhelpers/helpers/timezone_handling.py
+++ b/src/hdhelpers/helpers/timezone_handling.py
@@ -15,8 +15,8 @@ def _convert_to_optional_timezone(object_to_convert, to_timezone: str | None):
"""Convert object_to_convert to to_timezone if not None,
or to its own timezone if aware
or to UTC otherwise"""
- raise NotImplementedError(
- f"Not implemented for object_to_convert of type {type(object_to_convert).__name__}"
+ raise TypeError(
+ f"Entries to convert do not contain valid timestamps ({type(object_to_convert).__name__})"
)
@@ -52,6 +52,9 @@ def modify_timezone[T: (pd.Timestamp, datetime.datetime, pd.Series, pd.DataFrame
"""Converts time information of pandas objects to a certain timezone
This function is applicable to index and/or columns of pd.Series or pd.DataFrame as well as for single pd.Timestamp objects.
+ If time zone information is not defined in object to convert it is assumed that it is in UTC.
+ Please note that column_names and convert_index are not exclusive to enable modifying both at the same time.
+ To enable modifying the value of a series (not the index), please name the series and define the series' name in column_names.
Args:
object_to_convert (pd.Timestamp | pd.Series | pd.DataFrame): Timestamp, Series or DataFrame where timezone is modified
@@ -103,9 +106,7 @@ def modify_timezone[T: (pd.Timestamp, datetime.datetime, pd.Series, pd.DataFrame
if len(column_names) == 0:
if isinstance(object_to_convert, pd.Series):
- new_object.index = _convert_to_optional_timezone(
- pd.to_datetime(new_object.index), to_timezone
- )
+ new_object.index = _convert_to_optional_timezone(new_object.index, to_timezone)
msg = f"Converted index to datetime starting with {object_to_convert.index.min()}"
logger.debug(msg=msg)
elif isinstance(new_object, pd.DataFrame) and "timestamp" in new_object.columns:
@@ -123,9 +124,7 @@ def modify_timezone[T: (pd.Timestamp, datetime.datetime, pd.Series, pd.DataFrame
)
if convert_index:
- new_object.index = _convert_to_optional_timezone(
- pd.to_datetime(new_object.index), to_timezone
- )
+ new_object.index = _convert_to_optional_timezone(new_object.index, to_timezone)
if not isinstance(object_to_convert, pd.Series):
new_object.attrs = object_to_convert.attrs
diff --git a/tests/helpers/test_timezone_handling.py b/tests/helpers/test_timezone_handling.py
index 808a034..c8f8b88 100644
--- a/tests/helpers/test_timezone_handling.py
+++ b/tests/helpers/test_timezone_handling.py
@@ -51,7 +51,7 @@ def test_modify_timezone_timestamp_offset(timestamp, timezone, result):
def test_modify_timezone_good_dataframe(dataframe):
local_summertime = modify_timezone(
- dataframe, to_timezone="Europe/Berlin", column_names=["timestamp"]
+ dataframe, to_timezone="Europe/Berlin", column_names=["timestamp"], convert_index=False
)
# German summer time starts in last Sunday in March at 2 am. --> UTC 1am
@@ -109,17 +109,19 @@ def test_empty_dataframe():
assert modified_data.empty
-def test_named_series(series_summer):
+def test_named_series_using_column_name(series_summer):
data = pd.Series(series_summer.index)
data.name = "timestamp"
data.attrs = series_summer.attrs
- modified_data = modify_timezone(data, to_timezone="Europe/Berlin", column_names=["timestamp"])
+ modified_data = modify_timezone(
+ data, to_timezone="Europe/Berlin", column_names=["timestamp"], convert_index=False
+ )
assert modified_data[1].utcoffset() == datetime.timedelta(seconds=3600)
assert "foo" in modified_data.attrs
def test_named_series_using_index(series_summer):
- data = series_summer
+ data = series_summer.copy()
data.name = "timestamp"
modified_data = modify_timezone(data, to_timezone="Europe/Berlin")
assert modified_data.index[0].utcoffset() == datetime.timedelta(seconds=3600)
@@ -137,12 +139,6 @@ def test_column_not_known(series_summer, dataframe):
_ = modify_timezone(dataframe, to_timezone="Europe/Berlin", column_names=["timestamp2"])
-def test_modify_timezone_no_tz_known(series_summer):
- series_summer.index = series_summer.index.tz_localize(None)
- with pytest.raises(TypeError, match="Entries to convert do not contain valid timestamps*"):
- _ = modify_timezone(series_summer, to_timezone="Europe/Berlin")
-
-
def test_modify_timezone_multicolumn_dataframe(multicolumn_frame):
local_summertime = modify_timezone(
multicolumn_frame.copy(),
@@ -200,3 +196,21 @@ def test_modify_timestamp_datetime():
example_date = pd.to_datetime("2023-03-25 23:00", utc=True)
modified_timestamp = modify_timezone(example_date.to_pydatetime(), to_timezone="Europe/Berlin")
assert modified_timestamp.utcoffset() == datetime.timedelta(seconds=3600)
+
+
+def test_native_timestamp_handled_as_UTC(series_summer):
+ series_summer.index = series_summer.index.tz_localize(None)
+ modified_data = modify_timezone(series_summer.head(2), to_timezone="Europe/Berlin")
+ assert modified_data.index[0].utcoffset() == datetime.timedelta(seconds=3600)
+
+
+def test_modify_timezone_no_timestamp_as_index(series_summer):
+ with pytest.raises(TypeError, match="Entries to convert do not contain valid timestamps"):
+ _ = modify_timezone(
+ series_summer.head(2).reset_index(), to_timezone="Europe/Berlin", convert_index=True
+ )
+
+
+def test_modify_timezone_wrong_type(series_summer):
+ with pytest.raises(TypeError, match="object_to_convert is*"):
+ _ = modify_timezone(1, to_timezone="Europe/Berlin", convert_index=True)
diff --git a/uv.lock b/uv.lock
index 78341af..34e024b 100644
--- a/uv.lock
+++ b/uv.lock
@@ -263,7 +263,7 @@ wheels = [
[[package]]
name = "hdhelpers"
-version = "0.0.3"
+version = "0.0.4"
source = { editable = "." }
dependencies = [
{ name = "glom" },