3

How to convert pandas dataframe back to snowpark dataframe?

pandas_df = snowpark_df.to_pandas()
...
???
Raphael Roth
  • 26,751
  • 15
  • 88
  • 145
psabela
  • 324
  • 1
  • 3
  • 16
  • Can you give us more context? – Felipe Hoffa Aug 17 '22 at 00:51
  • A snowpark dataframe is a table in Snowflake. So, use `write_pandas()` to write the data in the dataframe back to a Snowflake table, and then you can set that table to be a snowpark dataframe. – Mike Walton Aug 17 '22 at 00:58
  • Basically getting snowflake table into Snowpark, dataframe, converting it to pandas to take advantage of the functionality, and once transformed, save it back to snowflake. – psabela Aug 17 '22 at 01:05
  • Mike, the write_pandas only works with snowflake connector, and not snowpack library, right? – psabela Aug 17 '22 at 01:08
  • 2
    Snowpark supports `write_pandas`. Proof: https://github.com/snowflakedb/snowpark-python/blob/75beddbedfb49eeca1ac25f88e420bf1c8fb145d/src/snowflake/snowpark/session.py#L970 – Felipe Hoffa Aug 17 '22 at 04:59

1 Answers1

5

Try this:

session.create_dataframe(pandas_df)

or alternatively this:

session.write_pandas(pandas_df, ...)

You can read about it in the docs here

Chris
  • 115
  • 6