modin.pandas.Series.to_snowpark¶
- Series.to_snowpark(index: bool = True, index_label: Optional[Union[Hashable, Sequence[Hashable]]] = None) DataFrame [source]¶
Convert the Snowpark pandas Series to a Snowpark DataFrame. Note that once converted to a Snowpark DataFrame, no ordering information will be preserved. You can call reset_index to generate a default index column that is the same as the row position before the call to_snowpark.
- Parameters:
index – bool, default True. Whether to keep the index columns in the result Snowpark DataFrame. If True, the index columns will be the first set of columns. Otherwise, no index column will be included in the final Snowpark DataFrame.
index_label – IndexLabel, default None. Column label(s) to use for the index column(s). If None is given (default) and index is True, then the original index column labels are used. A sequence should be given if the DataFrame uses MultiIndex, and the length of the given sequence should be the same as the number of index columns.
- Returns:
- Snowpark
DataFrame
A Snowpark DataFrame contains the index columns if index=True and all data columns of the Snowpark pandas DataFrame. The identifier for the Snowpark DataFrame will be the normalized quoted identifier with the same name as the pandas label.
- Snowpark
- Raises:
ValueError if duplicated labels occur among the index and data columns. –
ValueError if the label used for a index or data column is None. –
See also
to_snowpark
Series.to_snowpark
Note
The labels of the Snowpark pandas DataFrame or index_label provided will be used as Normalized Snowflake Identifiers of the Snowpark DataFrame. For details about Normalized Snowflake Identifiers, please refer to the Note in
read_snowflake()
Examples:
>>> ser = pd.Series([390., 350., 30., 20.], ... index=['Falcon', 'Falcon', 'Parrot', 'Parrot'], ... name="Max Speed") >>> ser Falcon 390.0 Falcon 350.0 Parrot 30.0 Parrot 20.0 Name: Max Speed, dtype: float64 >>> snowpark_df = ser.to_snowpark(index_label="Animal") >>> snowpark_df.order_by('"Max Speed"').show() -------------------------- |"Animal" |"Max Speed" | -------------------------- |Parrot |20.0 | |Parrot |30.0 | |Falcon |350.0 | |Falcon |390.0 | -------------------------- >>> snowpark_df = ser.to_snowpark(index=False) >>> snowpark_df.order_by('"Max Speed"').show() --------------- |"Max Speed" | --------------- |20.0 | |30.0 | |350.0 | |390.0 | --------------- MultiIndex usage >>> ser = pd.Series([390., 350., 30., 20.], ... index=pd.MultiIndex.from_tuples([('bar', 'one'), ('foo', 'one'), ('bar', 'two'), ('foo', 'three')], names=['first', 'second']), ... name="Max Speed") >>> ser first second bar one 390.0 foo one 350.0 bar two 30.0 foo three 20.0 Name: Max Speed, dtype: float64 >>> snowpark_df = ser.to_snowpark(index=True, index_label=['A', 'B']) >>> snowpark_df.order_by('"A"', '"B"').show() ----------------------------- |"A" |"B" |"Max Speed" | ----------------------------- |bar |one |390.0 | |bar |two |30.0 | |foo |one |350.0 | |foo |three |20.0 | ----------------------------- >>> snowpark_df = ser.to_snowpark(index=False) >>> snowpark_df.order_by('"Max Speed"').show() --------------- |"Max Speed" | --------------- |20.0 | |30.0 | |350.0 | |390.0 | ---------------