0
2

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.

pandas メモ

Last updated at Posted at 2021-03-11

サンプルデータ

import pandas as pd
from sklearn.datasets import load_iris

# データ取得(アイリスという花のデータセット)
iris = load_iris()
data = iris.data
columns = iris.feature_names

# pd.DataFrame
df = pd.DataFrame(data=data, columns=columns)

データ全体を確認

先頭からデータを表示: head()

df.head() # 引数なしで5件表示

df.head(10) # 引数分データを表示

末尾のデータを表示: tail()

df.tail() # 引数なしで5件表示

df.head(10) # 引数分データを表示

列(column)、行(index)の確認: columns, index

df.columns # 列

df.index # 行

各カラムの最大値、最小値: max(), min()

# 最大値
df.max()
# 最小値
df.min()

各カラムの平均、標準偏差: mean(), std()

df.mean() # 平均

df.std() # 標準偏差

最大、最小値や平均値をまとめて確認: describe()

df.describe()

データの中身を確認

データ型を確認: dtypes

df.dtypes

欠損値(NaN)の確認: isnull()

# 欠損値の有無
df.isnull().any()

# 欠損値の数
df.isnull().sum() # NaNの合計
0
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?