Reputation: 643
I have pandas 0.13.1 installed but pandas.read_stata()
fails to read .dta files created in Stata 13 format, with the error
TypeError: cannot concatenate 'str' and 'NoneType' objects
No problem at all with the same dataset saved in Stata 12 format.
I thought that the latest release of pandas (0.13.1) handled Stata 13 dataset files. Am I doing something wrong?
Upvotes: 2
Views: 1488
Reputation: 11102
My guess is you're not doing anything inherently wrong, but that your version of pandas can't handle Stata 13 dataset files. As documented in help dta, the format of Stata .dta datasets changed with the release of Stata 13.
Solution 1.
Update your pandas to v0.14.0 (May 31 , 2014):
read_stata now accepts Stata 13 format (GH4291)
Source: http://pandas.pydata.org/pandas-docs/stable/whatsnew.html
Solution 2.
If you have access to Stata, there are several ways of reverting to earlier/different formats that should work with your earlier version of pandas. See this answer:
Solution 3.
After some discussion in GitHub the problem pandas seems to have with Stata 13 datasets are string variables. So another solution could be converting the string to numeric type. See help encode
, which will create appropiate value labels; or maybe help real
or help destring
, if the strings happen to be just numbers in string type.
Upvotes: 4