LoginSignup
1
1

More than 5 years have passed since last update.

Pandas データフレーム。欠損値とinteger型。Chi-square。

Posted at

本日学んだことをメモ。

・Pandasのデータフレームの数値型の列に欠損値があると、その列は自動的にfloatになってしまう。Astypeでキャストを試みても、Round関数で四捨五入使用としても、Integerにしようとするとエラーが帰ってくる。「Nanはintegerにできない。」と。不便。
結局Str型に変更して、strの編集をする方針とした。

・pandasの列への関数の適応方法については、理解できていない。あとで整理する。

・pythonのScypiよりもRのChi-squareの方が欠損に関し、エラーが出ずらい(堅牢)だと考え、pandas dataframeをRのdataframeに変更しようと試みたが、できず。rpy2はバージョンの違いなのかうまくいかず。pypeRではやり方自体発見できず。Rのコードに慣れていれば、pypeRを使用し、リストを渡してRのベクトルにして、データフレームを作れば良いのだろうが、、、結局、Try exception構文を利用し、pythonのChi-squareのエラーを補足して、対応することとした。

pandas integerとNan
https://stackoverflow.com/questions/21287624/convert-pandas-column-containing-nans-to-dtype-int

Rとpythonのデータフレームの受け渡し
http://sinhrks.hatenablog.com/entry/2014/10/16/224948

pandasの列への関数の適応方法について
https://note.nkmk.me/python-pandas-map-applymap-apply/

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