snowflakedb / snowflakedb/snowpark-python
SNOW-1368516: Creating a dataframe from pandas dataframe with datetime objects fail to set the right column type
Open
@sfc-gh-yixie is already working on this.
Since May 7, 2024.
bug
local testing
status-triage_done
- Dominant language
- Python
- Stars
- 341
- Forks
- 155
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 27
Description
data = {
"pandas_datetime": ["2021-09-30 12:00:00", "2021-09-30 13:00:00"],
"date": [pd.to_datetime("2010-1-1"), pd.to_datetime("2011-1-1")],
"datetime.datetime": [
datetime.datetime(2010, 1, 1),
datetime.datetime(2010, 1, 1),
],
}
pdf = pd.DataFrame(data)
pdf["pandas_datetime"] = pd.to_datetime(pdf["pandas_datetime"])
df = session.create_dataframe(pdf)
print(df.schema)
prints
StructType([StructField('"pandas_datetime"', LongType(), nullable=True), StructField('"date"', LongType(), nullable=True), StructField('"datetime.datetime"', LongType(), nullable=True)])
which can be traced to utility function src/snowflake/snowpark/mock/_pandas_util.py::_extract_schema_and_data_from_pandas_df extracting the schema wrong. This is a bug that blocks the test tests/integ/test_dataframe.py::test_create_dataframe_with_pandas_df from being enabled to run against Local Testing.
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.
Assessment
This issue has not been assessed yet.