Skip to content

Commit 4bbebb5

Browse files
jaidevdsanand0
andauthored
REQ: Remove tzlocal as a dependency (#637)
* REQ: Remove tzlocal as a dependency Only InfluxDB requires this, we'll handle it later if needed. * BUG: Ensure datetime is time-zone aware See influxdata/influxdb-client-python#73 We need a timezone aware datetime. Python 3.3+ uses .aztimezone(None) to convert to local timezone https://docs.python.org/3/library/datetime.html#datetime.datetime.astimezone * GIT: avoid merge conflict with sa-packaging Co-authored-by: S Anand <[email protected]>
1 parent ff46413 commit 4bbebb5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

gramex/data.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -2004,14 +2004,12 @@ def _influxdb_client(
20042004

20052005

20062006
def _timestamp_df(df, index_col="_time"):
2007-
from tzlocal import get_localzone
2008-
2009-
now = datetime.now(get_localzone())
2007+
"""Add timestamp index by parsing `index_col` (default to now)."""
2008+
now = datetime.now().astimezone()
20102009
if index_col not in df:
20112010
df[index_col] = [now] * len(df)
20122011
else:
2013-
df[index_col] = pd.to_datetime(df[index_col], errors="coerce")
2014-
df[index_col].fillna(value=now, inplace=True)
2012+
df[index_col] = pd.to_datetime(df[index_col], errors="coerce").fillna(now)
20152013
return df.set_index(index_col)
20162014

20172015

0 commit comments

Comments
 (0)