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 3 years have passed since last update.

欠損値を特定の値で埋める

Last updated at Posted at 2020-03-28

##欠損値nanを埋めたいときに

###検証準備

#使用モジュール
import numpy as np
import pandas as pd

data=pd.DataFrame(np.arange(12).reshape(3, 4),columns=['col_0', 'col_1', 'col_2', 'col_3'],
                  index=['row_0', 'row_1', 'row_2'])

#Nanを入れる
data.loc['row_0','col_1']=np.nan
data

cap1.PNG

###NaNを埋める


#Nanを100で埋める
filldata=data.fillna(100)
filldata

cap2.PNG

できた!

######ちなみにdataを直接書き換えていないので注意

#もとのdataを表示
data

cap3.PNG

###参考URL

Pandasで欠損値処理

pandas.DataFrameの構造とその作成方法

【NANって何だ?】意味・pythonでの使い方を解説します!

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?