|
45 | 45 |
|
46 | 46 | _statafile_processing_params1 = """\
|
47 | 47 | convert_dates : boolean, defaults to True
|
48 |
| - Convert date variables to DataFrame time values |
| 48 | + Convert date variables to DataFrame time values. |
49 | 49 | convert_categoricals : boolean, defaults to True
|
50 |
| - Read value labels and convert columns to Categorical/Factor variables""" |
| 50 | + Read value labels and convert columns to Categorical/Factor variables.""" |
51 | 51 |
|
52 | 52 | _encoding_params = """\
|
53 | 53 | encoding : string, None or encoding
|
54 | 54 | Encoding used to parse the files. None defaults to latin-1."""
|
55 | 55 |
|
56 | 56 | _statafile_processing_params2 = """\
|
57 | 57 | index_col : string, optional, default: None
|
58 |
| - Column to set as index |
| 58 | + Column to set as index. |
59 | 59 | convert_missing : boolean, defaults to False
|
60 | 60 | Flag indicating whether to convert missing values to their Stata
|
61 | 61 | representations. If False, missing values are replaced with nan.
|
|
64 | 64 | StataMissingValue objects.
|
65 | 65 | preserve_dtypes : boolean, defaults to True
|
66 | 66 | Preserve Stata datatypes. If False, numeric data are upcast to pandas
|
67 |
| - default types for foreign data (float64 or int64) |
| 67 | + default types for foreign data (float64 or int64). |
68 | 68 | columns : list or None
|
69 | 69 | Columns to retain. Columns will be returned in the given order. None
|
70 |
| - returns all columns |
| 70 | + returns all columns. |
71 | 71 | order_categoricals : boolean, defaults to True
|
72 | 72 | Flag indicating whether converted categorical data are ordered."""
|
73 | 73 |
|
74 | 74 | _chunksize_params = """\
|
75 | 75 | chunksize : int, default None
|
76 | 76 | Return StataReader object for iterations, returns chunks with
|
77 |
| - given number of lines""" |
| 77 | + given number of lines.""" |
78 | 78 |
|
79 | 79 | _iterator_params = """\
|
80 | 80 | iterator : boolean, default False
|
81 |
| - Return StataReader object""" |
| 81 | + Return StataReader object.""" |
82 | 82 |
|
83 |
| -_read_stata_doc = """Read Stata file into DataFrame |
| 83 | +_read_stata_doc = """ |
| 84 | +Read Stata file into DataFrame. |
84 | 85 |
|
85 | 86 | Parameters
|
86 | 87 | ----------
|
87 | 88 | filepath_or_buffer : string or file-like object
|
88 |
| - Path to .dta file or object implementing a binary read() functions |
| 89 | + Path to .dta file or object implementing a binary read() functions. |
89 | 90 | %s
|
90 | 91 | %s
|
91 | 92 | %s
|
|
96 | 97 | -------
|
97 | 98 | DataFrame or StataReader
|
98 | 99 |
|
| 100 | +See Also |
| 101 | +-------- |
| 102 | +pandas.io.stata.StataReader : low-level reader for Stata data files |
| 103 | +pandas.DataFrame.to_stata: export Stata data files |
| 104 | +
|
99 | 105 | Examples
|
100 | 106 | --------
|
101 | 107 | Read a Stata dta file:
|
102 | 108 |
|
103 |
| ->>> df = pandas.read_stata('filename.dta') |
| 109 | +>>> import pandas as pd |
| 110 | +>>> df = pd.read_stata('filename.dta') |
104 | 111 |
|
105 | 112 | Read a Stata dta file in 10,000 line chunks:
|
106 | 113 |
|
107 |
| ->>> itr = pandas.read_stata('filename.dta', chunksize=10000) |
| 114 | +>>> itr = pd.read_stata('filename.dta', chunksize=10000) |
108 | 115 | >>> for chunk in itr:
|
109 |
| ->>> do_something(chunk) |
| 116 | +... do_something(chunk) |
110 | 117 | """ % (_statafile_processing_params1, _encoding_params,
|
111 | 118 | _statafile_processing_params2, _chunksize_params,
|
112 | 119 | _iterator_params)
|
@@ -2472,7 +2479,7 @@ def __init__(self, df, columns, version=117, byteorder=None):
|
2472 | 2479 |
|
2473 | 2480 | self.df = df
|
2474 | 2481 | self.columns = columns
|
2475 |
| - self._gso_table = OrderedDict((('', 0),)) |
| 2482 | + self._gso_table = OrderedDict((('', (0, 0)),)) |
2476 | 2483 | if byteorder is None:
|
2477 | 2484 | byteorder = sys.byteorder
|
2478 | 2485 | self._byteorder = _set_endianness(byteorder)
|
@@ -2674,15 +2681,16 @@ class StataWriter117(StataWriter):
|
2674 | 2681 | Examples
|
2675 | 2682 | --------
|
2676 | 2683 | >>> import pandas as pd
|
2677 |
| - >>> data = pd.DataFrame([[1.0, 1, 'a']], columns=['a', 'b']) |
| 2684 | + >>> from pandas.io.stata import StataWriter117 |
| 2685 | + >>> data = pd.DataFrame([[1.0, 1, 'a']], columns=['a', 'b', 'c']) |
2678 | 2686 | >>> writer = StataWriter117('./data_file.dta', data)
|
2679 | 2687 | >>> writer.write_file()
|
2680 | 2688 |
|
2681 |
| - Or with dates |
2682 |
| - >>> from datetime import datetime |
| 2689 | + Or with long strings stored in strl format |
| 2690 | +
|
2683 | 2691 | >>> data = pd.DataFrame([['A relatively long string'], [''], ['']],
|
2684 | 2692 | ... columns=['strls'])
|
2685 |
| - >>> writer = StataWriter117('./date_data_file.dta', data, |
| 2693 | + >>> writer = StataWriter117('./data_file_with_long_strings.dta', data, |
2686 | 2694 | ... convert_strl=['strls'])
|
2687 | 2695 | >>> writer.write_file()
|
2688 | 2696 | """
|
|
0 commit comments