question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pandas can not load Stata 16 data

See original GitHub issue

Code Sample

df = pd.read_stata('xx.dta')

Problem description

I was trying to use the above command to load Stata 16 data, but got an error saying

Version of given Stata file is not 104, 105, 108, 111 (Stata 7SE), 113 (Stata 8/9), 114 (Stata 10/11), 115 (Stata 12), 117 (Stata 13), or 118 (Stata 14)

I updated pandas to version 0.25.1, the issue persists. How could I load Stata 16 data without degrading the dataset? Thanks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shuai-zhoucommented, Jan 7, 2020

@shuai-zhou : Can you share the file that you’re trying to load?

cc @bashtage

@gfyoung I would like to, but the .dta is a large file (~500M) with 38548 variables (columns), and I figured out that I was wrong. I extracted a subset from the file and loaded it to pandas dataframe successfully. I guess the numbers of columns are an issue, not the Stata version.

0reactions
bashtagecommented, Jan 8, 2020

@shuai-zhou I was wrong – 119 are supported. So if you cannot import your file, we should try to figure out why.

Could you make a very small version to share – perhaps with a few observations?

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to read stata .dta file in python - pandas - Stack Overflow
Just use the read_table() of Pandas then make sure to include delim_whitespace=True and header=None.
Read more >
Python Integration: Pandas Package Causing Stata to Close
I have a recent version of Anaconda installed, and Stata is recently updated. However, when I try to load a Stata dataset into...
Read more >
Unable to import Stata 13 database files with read_stata() #7360
pandas v0.14.0 (May 31 , 2014) seems uncapable of importing Stata 13 datasets although according to this http://pandas.pydata.org/pandas-docs/ ...
Read more >
Stata/Python integration part 4: How to use Python packages
pandas is a popular Python package used for importing, exporting, and manipulating data. The package contains different modules for working ...
Read more >
Data (sfi.Data) — Python API documentation for Stata 16
Here nvar is the number of variables defined in the dataset currently loaded in Stata, which is returned by getVarCount() . nobs is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found