1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SnowflakeAdvent Calendar 2024

Day 6

Python on Snowflake でよく利用する関数

Last updated at Posted at 2024-12-21

Python on Snowflake でよく利用する関数

Python on Snowflake でよく利用する関数を紹介する.

  • 使用するウェアハウスをWAREHOUSEに指定
session.use_warehouse("<WAREHOUSE>")
  • 使用するロールをROLEに指定
session.use_role("<ROLE>")
  • 使用するデータベースをDATABASEに指定
session.use_database("<DATABASE>")
  • 使用するスキーマをSCHEMAに指定
session.use_schema("<SCHEMA>")
  • PandasDataFrameTABLE_NAMEに書き込み
session.write_pandas(<PandasDataFrame>,<TABLE_NAME>',overwrite=True)
  • PandasDataFrameをSnowflakeDataFrameに変換
session.create_dataframe("<PandasDataFrame>")
  • SnowflakeDataFrameをPandasDataFrameに変換
<SnowflakeDataFrame>.to_pandas()
  • SnowflakeDataFramTABLE_NAMEに書き込み
<SnowflakeDataFrame>.write.mode(overwrite).save_as_table("<TABLE_NAME>")
  • SQLの実行
session.sql("<SQL>")
  • SnowflakeDataFrameを出力画面に出力
<SnowflakeDataFrame>.show()
  • SnowflakeDataFrameのレコード数を出力
<SnowflakeDataFrame>.count()
  • SnowflakeDataFrameのカラム名を出力
<SnowflakeDataFrame>.columns
  • SnowflakeDataFrameのカラム名COLUMN_NAMEのカラムを抽出
<SnowflakeDataFrame>.select("<COLUMN_NAME>")
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?