1
我有一個大小爲153895行x 644列(從csv文件讀取)的熊貓數據框,並且有幾列是字符串,其他是整數和浮點數。我試圖將其保存爲Rda文件。convert_to_r_dataframe給出錯誤無屬性dtype
我想:
import pandas.rpy.common as com
myDFinR = com.convert_to_r_dataframe(myDF)
我得到以下錯誤:
Traceback (most recent call last):
File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\IPython\core\interactiveshell.py", line 2828, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-101-7d2a8ae98ea4>", line 1, in <module>
dDataR=com.convert_to_r_dataframe(dData)
File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\pandas\rpy\common.py", line 305, in convert_to_r_dataframe
value_type = value.dtype.type
File "C:\PF\WinPython-64bit-3.3.3.3\python-3.3.3.amd64\lib\site-packages\pandas\core\generic.py", line 1815, in __getattr__
(type(self).__name__, name))
AttributeError: 'DataFrame' object has no attribute 'dtype'
我試圖做myDF.dtypes
,並沒有給我什麼不尋常的輸出
col1 object
col2 object
col3 int64
...
col642 float64
col643 float64
col644 float64
Length: 644, dtype: object
當我試過for i,j in enumerate(myDF.columns): print(i,":",myDF[j].dtype)
,然後它在列359給我一個錯誤。但是,如果我嘗試myDF[[359]].dtypes
它給我
col359 float64
dtype: object
可能是什麼問題?
涼爽。謝謝,讓我看看。 – uday
是的,這是問題所在 – uday