LoginSignup
1
0

More than 3 years have passed since last update.

[Tips]Pythonで関数をつなげるときの見やすい書き方

Posted at

この書き方知らなかった&真似しようっと思った書き方を紹介します
データ分析やデータ前処理をする時に関数を何個も実行することあると思いますが下記みたいにカッコをつけることで関数を改行して書くことができます。
これ見やすくなるので好きです。

import pandas as pd
from sklearn.datasets import load_iris
iris = load_iris()

(
data
.where(data['sepal length (cm)'] > 5)
.where(data['petal length (cm)'] > 5)
.sum()
)

以上!

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