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

データを整形するときに困ったこと備忘録

Posted at

この記事はスクレイピングしてきたデータ型がいろいろ変だったりしたときに行った処理の備忘録です。

#データの型を確認する

df['column名'].dtype #DataFrame
np.dtype() #numpy配列

#データ型の変更

df['column名'].astype(int) #intに変換
df['column名'].dtype(float) #floatに変換
df['column名'].dtype(str) #文字列に変換

#欠損値の確認

df.isnull()

#欠損値を削除する

df.dropna()

#pandasの行削除

df.drop(行数)

#pandasに列追加

df['新しい列の名前']=[a,b,c,d,...]
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?