0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Snowflake Pythonワークシートでpandasパッケージを選択するとエラーになるのだが

0
Posted at

結論

選択しなければいい。

image.png

もしくは、pandas 〜1.5.3 を選択する。

image.png

なんかエラーが出るようになった?

Pythonワークシートでpandasパッケージを選択して以下のようなコードを実行しようとした。

import snowflake.snowpark as snowpark
import pandas as pd
from datetime import datetime


def main(session: snowpark.Session): 
    df = session.create_dataframe(
        pd.DataFrame(
            [[1, datetime.now().strftime("%m/%d/%Y %H:%M:%S")]],
            columns=["No.", "timestamp"]
        )
    )
    df.show()

pandasパッケージは以下のように選択しておく。

image.png

いざ実行。

image.png

100357 (P0000): Cannot create a Python function with the specified packages. Please check your packages specification and try again.

エラー...?
もしかしてpandasはあかんの?

と思って、とりあえずInstalled Packagesからpandasを外して再実行してみた。

すると...

image.png

いけるんかーい。

どうやらPythonワークシートではpandasは指定せずとも使えるらしい。
選択が必須だと勘違いしていた...。

元々pandasを選択していたのか、選択せずに実行していたのか...
最近このような挙動になったのか...
覚えてない。分からない。

念の為pandasバージョンを 2.0.3 -> 1.5.3に変えてみると...

image.png

いけた。
バージョン問題でもあるらしい。

何も指定しない場合の挙動は?

確認してみる。

import snowflake.snowpark as snowpark
import pandas as pd


def main(session: snowpark.Session): 
    print(pd.__version__)

image.png

なるほど。
つまり、今(2023/11/3頃)のところは以下の模様。

  • pandasパッケージを指定せずとも使える
  • 今は1.5.3がPythonワークシートで使用できる最新版
  • 指定しない場合はデフォルトでpandas 1.5.3 がインストールされている状態になっている
  • あえて指定する場合は使用できるバージョンを選択する

ん〜。
とりあえずミニマムでimportしていたから気付けたからいいものの。
いろんなパッケージを選択してimportしているとなかなか分からんて...

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?