{"id":25602169,"url":"https://github.com/snowflakedb/snowpark-python","last_synced_at":"2026-04-02T20:27:31.304Z","repository":{"id":37047645,"uuid":"359558698","full_name":"snowflakedb/snowpark-python","owner":"snowflakedb","description":"Snowflake Snowpark Python API","archived":false,"fork":false,"pushed_at":"2025-05-12T21:29:46.000Z","size":58621,"stargazers_count":298,"open_issues_count":182,"forks_count":126,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-05-12T21:40:48.909Z","etag":null,"topics":["data-analytics","data-engineering","data-science","dataframe","python","snowflake","sql"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snowflakedb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-19T18:24:15.000Z","updated_at":"2025-05-12T17:49:39.000Z","dependencies_parsed_at":"2023-09-25T02:16:16.969Z","dependency_job_id":"e59c9d79-4f42-40f4-8f35-5b10ef1e24b9","html_url":"https://github.com/snowflakedb/snowpark-python","commit_stats":{"total_commits":627,"total_committers":35,"mean_commits":"17.914285714285715","dds":0.7145135566188198,"last_synced_commit":"814a4a168195a1119fe61edec5e590def8b0a730"},"previous_names":[],"tags_count":54,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowflakedb%2Fsnowpark-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowflakedb%2Fsnowpark-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowflakedb%2Fsnowpark-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowflakedb%2Fsnowpark-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snowflakedb","download_url":"https://codeload.github.com/snowflakedb/snowpark-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253829909,"owners_count":21970988,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-analytics","data-engineering","data-science","dataframe","python","snowflake","sql"],"created_at":"2025-02-21T16:48:45.703Z","updated_at":"2026-04-02T20:27:31.298Z","avatar_url":"https://github.com/snowflakedb.png","language":"Python","readme":"# Snowflake Snowpark Python and Snowpark pandas APIs\n\n[![Build and Test](https://github.com/snowflakedb/snowpark-python/actions/workflows/precommit.yml/badge.svg)](https://github.com/snowflakedb/snowpark-python/actions/workflows/precommit.yml)\n[![codecov](https://codecov.io/gh/snowflakedb/snowpark-python/branch/main/graph/badge.svg)](https://codecov.io/gh/snowflakedb/snowpark-python)\n[![PyPi](https://img.shields.io/pypi/v/snowflake-snowpark-python.svg)](https://pypi.org/project/snowflake-snowpark-python/)\n[![License Apache-2.0](https://img.shields.io/:license-Apache%202-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.txt)\n[![Codestyle Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nThe Snowpark library provides intuitive APIs for querying and processing data in a data pipeline.\nUsing this library, you can build applications that process data in Snowflake without having to move data to the system where your application code runs.\n\n[Source code][source code] | [Snowpark Python developer guide][Snowpark Python developer guide] | [Snowpark Python API reference][Snowpark Python api references] | [Snowpark pandas developer guide][Snowpark pandas developer guide] | [Snowpark pandas API reference][Snowpark pandas api references] | [Product documentation][snowpark] | [Samples][samples]\n\n## Getting started\n\n### Have your Snowflake account ready\nIf you don't have a Snowflake account yet, you can [sign up for a 30-day free trial account][sign up trial].\n\n### Create a Python virtual environment\nYou can use [miniconda][miniconda], [anaconda][anaconda], or [virtualenv][virtualenv]\nto create a Python 3.9, 3.10, 3.11, 3.12 or 3.13 virtual environment.\n\nFor Snowpark pandas, only Python 3.9, 3.10, or 3.11 is supported.\n\nTo have the best experience when using it with UDFs, [creating a local conda environment with the Snowflake channel][use snowflake channel] is recommended.\n\n### Install the library to the Python virtual environment\n```bash\npip install snowflake-snowpark-python\n```\nTo use the [Snowpark pandas API][Snowpark pandas developer guide], you can optionally install the following, which installs [modin][modin] in the same environment. The Snowpark pandas API provides a familiar interface for pandas users to query and process data directly in Snowflake.\n```bash\npip install \"snowflake-snowpark-python[modin]\"\n```\n\n### Create a session and use the Snowpark Python API\n```python\nfrom snowflake.snowpark import Session\n\nconnection_parameters = {\n  \"account\": \"\u003cyour snowflake account\u003e\",\n  \"user\": \"\u003cyour snowflake user\u003e\",\n  \"password\": \"\u003cyour snowflake password\u003e\",\n  \"role\": \"\u003csnowflake user role\u003e\",\n  \"warehouse\": \"\u003csnowflake warehouse\u003e\",\n  \"database\": \"\u003csnowflake database\u003e\",\n  \"schema\": \"\u003csnowflake schema\u003e\"\n}\n\nsession = Session.builder.configs(connection_parameters).create()\n# Create a Snowpark dataframe from input data\ndf = session.create_dataframe([[1, 2], [3, 4]], schema=[\"a\", \"b\"]) \ndf = df.filter(df.a \u003e 1)\nresult = df.collect()\ndf.show()\n\n# -------------\n# |\"A\"  |\"B\"  |\n# -------------\n# |3    |4    |\n# -------------\n```\n\n### Create a session and use the Snowpark pandas API\n```python\nimport modin.pandas as pd\nimport snowflake.snowpark.modin.plugin\nfrom snowflake.snowpark import Session\n\nCONNECTION_PARAMETERS = {\n    'account': '\u003cmyaccount\u003e',\n    'user': '\u003cmyuser\u003e',\n    'password': '\u003cmypassword\u003e',\n    'role': '\u003cmyrole\u003e',\n    'database': '\u003cmydatabase\u003e',\n    'schema': '\u003cmyschema\u003e',\n    'warehouse': '\u003cmywarehouse\u003e',\n}\nsession = Session.builder.configs(CONNECTION_PARAMETERS).create()\n\n# Create a Snowpark pandas dataframe from input data\ndf = pd.DataFrame([['a', 2.0, 1],['b', 4.0, 2],['c', 6.0, None]], columns=[\"COL_STR\", \"COL_FLOAT\", \"COL_INT\"])\ndf\n#   COL_STR  COL_FLOAT  COL_INT\n# 0       a        2.0      1.0\n# 1       b        4.0      2.0\n# 2       c        6.0      NaN\n\ndf.shape\n# (3, 3)\n\ndf.head(2)\n#   COL_STR  COL_FLOAT  COL_INT\n# 0       a        2.0        1\n# 1       b        4.0        2\n\ndf.dropna(subset=[\"COL_INT\"], inplace=True)\n\ndf\n#   COL_STR  COL_FLOAT  COL_INT\n# 0       a        2.0        1\n# 1       b        4.0        2\n\ndf.shape\n# (2, 3)\n\ndf.head(2)\n#   COL_STR  COL_FLOAT  COL_INT\n# 0       a        2.0        1\n# 1       b        4.0        2\n\n# Save the result back to Snowflake with a row_pos column.\ndf.reset_index(drop=True).to_snowflake('pandas_test2', index=True, index_label=['row_pos'])\n```\n\n## Samples\nThe [Snowpark Python developer guide][Snowpark Python developer guide], [Snowpark Python API references][Snowpark Python api references], [Snowpark pandas developer guide][Snowpark pandas developer guide], and [Snowpark pandas api references][Snowpark pandas api references] have basic sample code.\n[Snowflake-Labs][snowflake lab sample code] has more curated demos.\n\n## Logging\nConfigure logging level for `snowflake.snowpark` for Snowpark Python API logs.\nSnowpark uses the [Snowflake Python Connector][python connector].\nSo you may also want to configure the logging level for `snowflake.connector` when the error is in the Python Connector.\nFor instance,\n```python\nimport logging\nfor logger_name in ('snowflake.snowpark', 'snowflake.connector'):\n    logger = logging.getLogger(logger_name)\n    logger.setLevel(logging.DEBUG)\n    ch = logging.StreamHandler()\n    ch.setLevel(logging.DEBUG)\n    ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))\n    logger.addHandler(ch)\n```\n\n## Reading and writing to pandas DataFrame\n\nSnowpark Python API supports reading from and writing to a pandas DataFrame via the [to_pandas][to_pandas] and [write_pandas][write_pandas] commands. \n\nTo use these operations, ensure that pandas is installed in the same environment. You can install pandas alongside Snowpark Python by executing the following command:\n```bash\npip install \"snowflake-snowpark-python[pandas]\"\n```\nOnce pandas is installed, you can convert between a Snowpark DataFrame and pandas DataFrame as follows: \n```python\ndf = session.create_dataframe([[1, 2], [3, 4]], schema=[\"a\", \"b\"])\n# Convert Snowpark DataFrame to pandas DataFrame\npandas_df = df.to_pandas() \n# Write pandas DataFrame to a Snowflake table and return Snowpark DataFrame\nsnowpark_df = session.write_pandas(pandas_df, \"new_table\", auto_create_table=True)\n```\n\nSnowpark pandas API also supports writing to pandas: \n```python\nimport modin.pandas as pd\ndf = pd.DataFrame([[1, 2], [3, 4]], columns=[\"a\", \"b\"])\n# Convert Snowpark pandas DataFrame to pandas DataFrame\npandas_df = df.to_pandas() \n```\n\nNote that the above Snowpark pandas commands will work if Snowpark is installed with the `[modin]` option, the additional `[pandas]` installation is not required.\n\n## Verifying Package Signatures\n\nTo ensure the authenticity and integrity of the Python package, follow the steps below to verify the package signature using `cosign`.\n\n**Steps to verify the signature:**\n- Install cosign:\n  - This example is using golang installation: [installing-cosign-with-go](https://edu.chainguard.dev/open-source/sigstore/cosign/how-to-install-cosign/#installing-cosign-with-go)\n- Download the file from the repository like pypi:\n  - https://pypi.org/project/snowflake-snowpark-python/#files\n- Download the signature files from the release tag, replace the version number with the version you are verifying:\n  - https://github.com/snowflakedb/snowpark-python/releases/tag/v1.22.1\n- Verify signature:\n  ````bash\n  # replace the version number with the version you are verifying\n  ./cosign verify-blob snowflake_snowpark_python-1.22.1-py3-none-any.whl  \\\n  --certificate snowflake_snowpark_python-1.22.1-py3-none-any.whl.crt \\\n  --certificate-identity https://github.com/snowflakedb/snowpark-python/.github/workflows/python-publish.yml@refs/tags/v1.22.1 \\\n  --certificate-oidc-issuer https://token.actions.githubusercontent.com \\\n  --signature snowflake_snowpark_python-1.22.1-py3-none-any.whl.sig\n  Verified OK\n  ````\n\n## Contributing\nPlease refer to [CONTRIBUTING.md][contributing].\n\n[add other sample code repo links]: # (Developer advocacy is open-sourcing a repo that has excellent sample code. The link will be added here.)\n\n[Snowpark Python developer guide]: https://docs.snowflake.com/en/developer-guide/snowpark/python/index.html\n[Snowpark Python api references]: https://docs.snowflake.com/en/developer-guide/snowpark/reference/python/index.html\n[Snowpark pandas developer guide]: https://docs.snowflake.com/developer-guide/snowpark/python/snowpark-pandas\n[Snowpark pandas api references]: https://docs.snowflake.com/developer-guide/snowpark/reference/python/latest/modin/index\n[snowpark]: https://www.snowflake.com/snowpark\n[sign up trial]: https://signup.snowflake.com\n[source code]: https://github.com/snowflakedb/snowpark-python\n[miniconda]: https://docs.conda.io/en/latest/miniconda.html\n[anaconda]: https://www.anaconda.com/\n[virtualenv]: https://docs.python.org/3/tutorial/venv.html\n[config pycharm interpreter]: https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html\n[python connector]: https://pypi.org/project/snowflake-connector-python/\n[use snowflake channel]: https://docs.snowflake.com/en/developer-guide/udf/python/udf-python-packages.html#local-development-and-testing\n[snowflake lab sample code]: https://github.com/Snowflake-Labs/snowpark-python-demos\n[samples]: https://github.com/snowflakedb/snowpark-python/blob/main/README.md#samples\n[contributing]: https://github.com/snowflakedb/snowpark-python/blob/main/CONTRIBUTING.md\n[to_pandas]: https://docs.snowflake.com/developer-guide/snowpark/reference/python/latest/snowpark/api/snowflake.snowpark.DataFrame.to_pandas\n[write_pandas]: https://docs.snowflake.com/developer-guide/snowpark/reference/python/latest/snowpark/api/snowflake.snowpark.Session.write_pandas\n[modin]: https://github.com/modin-project/modin\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowflakedb%2Fsnowpark-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnowflakedb%2Fsnowpark-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowflakedb%2Fsnowpark-python/lists"}