larray.read_stata

larray.read_stata(filepath_or_buffer, index_col=None, sort_rows=False, sort_columns=False, **kwargs) Array[source]

Read Stata .dta file and returns an Array with the contents.

Parameters
filepath_or_bufferstr or file-like object

Path to .dta file or a file handle.

index_colstr or None, optional

Name of column to set as index. Defaults to None.

sort_rowsbool, optional

Whether to sort the rows alphabetically (sorting is more efficient than not sorting). This only makes sense in combination with index_col. Defaults to False.

sort_columnsbool, optional

Whether to sort the columns alphabetically (sorting is more efficient than not sorting). Defaults to False.

Returns
Array

See also

Array.to_stata

Notes

The round trip to Stata (Array.to_stata followed by read_stata) loose the name of the “column” axis.

Examples

>>> read_stata('test.dta')                   
{0}\{1}  row  country  sex
      0    0       BE    F
      1    1       FR    M
      2    2       FR    F
>>> read_stata('test.dta', index_col='row')  
row\{1}  country  sex
      0       BE    F
      1       FR    M
      2       FR    F