Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1552772: FutureWarning from Pandas about indexing in mock._pandas_util #1967

Closed
NickFishr opened this issue Jul 23, 2024 · 3 comments
Closed
Assignees
Labels
local testing Local Testing issues/PRs status-triage_done Initial triage done, will be further handled by the driver team

Comments

@NickFishr
Copy link
Contributor

  1. What version of Python are you using?

    Python 3.11.0rc1 (main, Aug 12 2022, 10:02:14) [GCC 11.2.0]
    
  2. What are the Snowpark Python and pandas versions in the environment?

    pandas==2.2.1
    snowflake-snowpark-python==1.20.0
  3. What did you do?

    Created a local testing session and tried to create some Snowpark dataframes from Pandas ones.

    import pandas as pd
    from snowflake.snowpark import Session
    
    session = Session.builder.config("local_testing", True).create()
    
    pandas_df = pd.DataFrame({"Timestamp": [pd.to_datetime(1490195805, unit="s")]})
    df = session.create_dataframe(pandas_df)
    
    pandas_df = pd.DataFrame([[1.0]], columns=["A"], dtype=pd.Float64Dtype())
    df = session.create_dataframe(pandas_df)
  4. What did you expect to see?

    No warnings.

    Instead Pandas threw the following warnings:

    /tmp/snowpark-python/src/snowflake/snowpark/mock/_pandas_util.py:96: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
      if isinstance(data.dtypes[col_idx], pd.DatetimeTZDtype):
    /tmp/snowpark-python/src/snowflake/snowpark/mock/_functions.py:811: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
      data = row[0]
    /tmp/snowpark-python/src/snowflake/snowpark/mock/_pandas_util.py:82: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
      if isinstance(data.dtypes[col_idx], PANDAS_INTEGER_TYPES)
    /tmp/snowpark-python/src/snowflake/snowpark/mock/_pandas_util.py:83: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
      else float(str(data.iloc[row_idx][col_idx]))
    

Additional Notes

This is possibly not a real bug and could've been muted with a warnings.simplefilter (like here).

But it is a FutureWarning from Pandas so it will probably come back later to bite us and it seems easy to fix.

@NickFishr NickFishr added bug Something isn't working local testing Local Testing issues/PRs needs triage Initial RCA is required labels Jul 23, 2024
@github-actions github-actions bot changed the title FutureWarning from Pandas about indexing in mock._pandas_util SNOW-1552772: FutureWarning from Pandas about indexing in mock._pandas_util Jul 23, 2024
@sfc-gh-sghosh sfc-gh-sghosh self-assigned this Jul 26, 2024
@sfc-gh-sghosh
Copy link

Hello @NickFishr ,

Thank you for raising the issue, yes, we can see the warning with local_testing. There is no issue with regular sessions.
Will update.

Regards,
Sujan

@sfc-gh-sghosh sfc-gh-sghosh added status-triage_done Initial triage done, will be further handled by the driver team and removed bug Something isn't working needs triage Initial RCA is required labels Jul 26, 2024
@sfc-gh-aling
Copy link
Contributor

thanks for the PR! we will merge once the tests pass

@sfc-gh-aling
Copy link
Contributor

PR merged, it will be carried in our next release, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
local testing Local Testing issues/PRs status-triage_done Initial triage done, will be further handled by the driver team
Projects
None yet
Development

No branches or pull requests

3 participants