SNOW-788985: Timezone gets removed when creating a DataFrame
@sfc-gh-ashahi is already working on this.
Since Mar 20, 2024.
Assessment
This issue has not been assessed yet.
Description
Bug Description
The code snippets shown assume that a Snowpark session is already created
Pandas
from datetime import datetime
def cv(*args):
return [datetime.strptime(t, "%Y-%m-%d %H:%M:%S%z") for t in args]
df1 = pd.DataFrame({"TIME": cv("2021-01-01 23:00:00+01:00", "2021-01-02 23:00:00+02:00")})
display(df1)
df2 = session.createDataFrame(df1).to_pandas()
display(df2)
The python code above will output the result shown below. The timezones of 'df2' are removed, which shouldn't happen.
df1: '2021-01-01 23:00:00+01:00', '2021-01-02 23:00:00+02:00'
df2: '2021-01-01 22:00:00', '2021-01-02 21:00:00'
When schema is specified
from snowflake.snowpark.types import (
StructField,
StructType,
TimestampType,
)
schema = StructType([StructField("a", TimestampType())])
df = session.create_dataframe(
[["2021-01-01 23:00:00+01:00"], ["2021-01-02 23:00:00+02:00"]],
schema,
).to_pandas()
display(df)
When specifying the schema, the only type of Timestamp available is 'TimestampType', which also removes the timezone:
Displays: '2021-01-01 23:00:00', '2021-01-02 23:00:00'
When the schema is inferred, the date gets saved as a string.
- Dominant language
- Python
- Stars
- 341
- Forks
- 155
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 27
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from snowflakedb/snowpark-python
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
snowflakedb/snowpark-python#4333 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 62/100
snowflakedb/snowpark-python#3873 · 1 comment ·
-
bug status-triage_done
snowflakedb/snowpark-python#4228 · 2 comments · 1 reaction · 2 assignees ·
-
status-triage_done
snowflakedb/snowpark-python#4220 · 4 comments · 1 reaction · 2 assignees ·
-
bug local testing status-triage_done
snowflakedb/snowpark-python#4111 · 1 comment · 2 assignees ·
All issues in snowflakedb/snowpark-python
Similar issues
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100