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.

Parquet形式のファイルを作りたい

Posted at

遭遇した問題

PySparkで以下の様に書いて実行しても何故かdf.parquetという名の空フォルダが作成されてしまいました。

df.write.parquet('path/df.parquet')

そこで、少し手間ですがjupyterでpandasを使いParquet形式のファイルを作成することにしました。

#ライブラリをインポート。
import pandas as pd
#CSVファイル読み込み。
df = pd.read_csv('path/df.csv')

ここでいきなり

df.to_parquet('path/df.parquet')

と書いて実行してもうまくいかず、次の準備が必要でした。

!pip install pyarrow

これで先のコードを実行するとうまくParquet形式のファイルを作成できました。

作成したファイルをPySparkで読み込むには以下の様に書けば大丈夫です。

Df = spark.read.parquet('path/df.parquet', header=True, inferSchema=True)
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?