Kanaries / pygwalker

PyGWalker: Turn your pandas dataframe into an interactive UI for visual analysis
https://kanaries.net/pygwalker
Apache License 2.0
13.45k stars 704 forks source link

Time zone changed to local TZ in Jupyter Lab #395

Closed rzzldzzl closed 10 months ago

rzzldzzl commented 10 months ago

Hi -

When a pandas dataframe is created with a datetime64[ns, UTC] column, pygwalker converts the time to the local time zone. How do I keep this from happening?

sql = '''select now() time, 1 count'''
cursor = conn.cursor()
cursor.execute(sql)
df = pd.DataFrame(cursor.fetchall())
print(df)

                              time  count
0 2024-01-16 13:09:34.944647+00:00      1
df.info()

<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1 entries, 0 to 0
Data columns (total 2 columns):
 #   Column  Non-Null Count  Dtype              
---  ------  --------------  -----              
 0   time    1 non-null      datetime64[ns, UTC]
 1   count   1 non-null      int64              
dtypes: datetime64[ns, UTC](1), int64(1)
memory usage: 148.0 bytes
walker=pyg.walk(df)

image

Thanks, Joe

longxiaofei commented 10 months ago

Hi @rzzldzzl , There is currently no way to fix it, unless you add a time zone offset to the original time field(this is obviously unreasonable).

Would it be better if users could configure the time zone offset themselves in the UI?

This feature will be launched this week.

rzzldzzl commented 10 months ago

@longxiaofei -

Would it be better if users could configure the time zone offset themselves in the UI?

Yes!

This feature will be launched this week.

Looking forward to it!

Thanks!

longxiaofei commented 10 months ago

A pre-release version of pygwalker was released: pip install pygwalker==0.4.3a0.

It includes the feature to modify time zones, but it may be some flaws(only works on the visualization tab).

details refer it: https://github.com/Kanaries/graphic-walker/pull/297.

image

rzzldzzl commented 10 months ago

Nice! Works as expected. Thanks!