Skip to content

Commit

Permalink
ENH: Added StataReader and StataWriter (pandas-dev#1512)
Browse files Browse the repository at this point in the history
  • Loading branch information
PKEuS committed May 15, 2013
1 parent e82003f commit 443c737
Show file tree
Hide file tree
Showing 8 changed files with 1,239 additions and 0 deletions.
29 changes: 29 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,6 +1280,35 @@ def from_csv(cls, path, header=0, sep=',', index_col=0,
parse_dates=parse_dates, index_col=index_col,
encoding=encoding)

@classmethod
def from_dta(dta, path, parse_dates=True, convert_categoricals=True, encoding=None, index_col=None):
"""
Read Stata file into DataFrame
Parameters
----------
path : string file path or file handle / StringIO
parse_dates : boolean, default True
Convert date variables to DataFrame time values
convert_categoricals : boolean, default True
Read value labels and convert columns to Categorical/Factor variables
encoding : string, None or encoding, default None
Encoding used to parse the files. Note that Stata doesn't
support unicode. None defaults to cp1252.
index_col : int or sequence, default None
Column to use for index. If a sequence is given, a MultiIndex
is used. Different default from read_table
Notes
-----
Returns
-------
y : DataFrame
"""
from pandas.io.parsers import read_stata
return read_stata(path, parse_dates=parse_dates, convert_categoricals=convert_categoricals, encoding=encoding, index=index_col)

def to_sparse(self, fill_value=None, kind='block'):
"""
Convert to SparseDataFrame
Expand Down
Loading

0 comments on commit 443c737

Please sign in to comment.