@@ -3,9 +3,9 @@ import datetime
3
3
from io import BytesIO
4
4
from types import TracebackType
5
5
from typing import (
6
- Hashable ,
7
6
Literal ,
8
7
Sequence ,
8
+ overload ,
9
9
)
10
10
11
11
import numpy as np
@@ -18,10 +18,12 @@ from pandas._typing import (
18
18
FilePath ,
19
19
HashableT ,
20
20
ReadBuffer ,
21
+ StataDateFormat ,
21
22
StorageOptions ,
22
23
WriteBuffer ,
23
24
)
24
25
26
+ @overload
25
27
def read_stata (
26
28
path : FilePath | ReadBuffer [bytes ],
27
29
convert_dates : bool = ...,
@@ -32,70 +34,47 @@ def read_stata(
32
34
columns : list [HashableT ] | None = ...,
33
35
order_categoricals : bool = ...,
34
36
chunksize : int | None = ...,
35
- iterator : bool = ...,
37
+ * ,
38
+ iterator : Literal [True ],
36
39
compression : CompressionOptions = ...,
37
40
storage_options : StorageOptions = ...,
38
- ) -> DataFrame | StataReader : ...
39
-
40
- stata_epoch : datetime .datetime = ...
41
- excessive_string_length_error : str
41
+ ) -> StataReader : ...
42
+ @overload
43
+ def read_stata (
44
+ path : FilePath | ReadBuffer [bytes ],
45
+ convert_dates : bool ,
46
+ convert_categoricals : bool ,
47
+ index_col : str | None ,
48
+ convert_missing : bool ,
49
+ preserve_dtypes : bool ,
50
+ columns : list [HashableT ] | None ,
51
+ order_categoricals : bool ,
52
+ chunksize : int | None ,
53
+ iterator : Literal [True ],
54
+ compression : CompressionOptions = ...,
55
+ storage_options : StorageOptions = ...,
56
+ ) -> StataReader : ...
57
+ @overload
58
+ def read_stata (
59
+ path : FilePath | ReadBuffer [bytes ],
60
+ convert_dates : bool = ...,
61
+ convert_categoricals : bool = ...,
62
+ index_col : str | None = ...,
63
+ convert_missing : bool = ...,
64
+ preserve_dtypes : bool = ...,
65
+ columns : list [HashableT ] | None = ...,
66
+ order_categoricals : bool = ...,
67
+ chunksize : int | None = ...,
68
+ iterator : Literal [False ] = ...,
69
+ compression : CompressionOptions = ...,
70
+ storage_options : StorageOptions = ...,
71
+ ) -> DataFrame : ...
42
72
43
73
class PossiblePrecisionLoss (Warning ): ...
44
-
45
- precision_loss_doc : str
46
-
47
74
class ValueLabelTypeMismatch (Warning ): ...
48
-
49
- value_label_mismatch_doc : str
50
-
51
75
class InvalidColumnName (Warning ): ...
52
76
53
- invalid_name_doc : str
54
-
55
- class StataValueLabel :
56
- labname : Hashable = ...
57
- value_labels : list [tuple [float , str ]] = ...
58
- text_len : int = ...
59
- off : npt .NDArray [np .int32 ] = ...
60
- val : npt .NDArray [np .int32 ] = ...
61
- txt : list [bytes ] = ...
62
- n : int = ...
63
- len : int = ...
64
- def __init__ (
65
- self , catarray : pd .Series , encoding : Literal ["latin-1" , "utf-8" ] = ...
66
- ) -> None : ...
67
- def generate_value_label (self , byteorder : str ) -> bytes : ...
68
-
69
- class StataMissingValue :
70
- MISSING_VALUES : dict [float , str ] = ...
71
- bases : tuple [int , int , int ] = ...
72
- float32_base : bytes = ...
73
- increment : int = ...
74
- int_value : int = ...
75
- float64_base : bytes = ...
76
- BASE_MISSING_VALUES : dict [str , int ] = ...
77
- def __init__ (self , value : float ) -> None : ...
78
- def __eq__ (self , other : object ) -> bool : ...
79
- @property
80
- def string (self ) -> str : ...
81
- @property
82
- def value (self ) -> float : ...
83
- @classmethod
84
- def get_base_missing_value (cls , dtype ): ...
85
-
86
77
class StataParser :
87
- DTYPE_MAP : dict [int , np .dtype ] = ...
88
- DTYPE_MAP_XML : dict [int , np .dtype ] = ...
89
- TYPE_MAP : list [tuple [int | str , ...]] = ...
90
- TYPE_MAP_XML : dict [int , str ] = ...
91
- VALID_RANGE : dict [
92
- str ,
93
- tuple [int , int ] | tuple [np .float32 , np .float32 ] | tuple [np .float64 , np .float64 ],
94
- ] = ...
95
- OLD_TYPE_MAPPING : dict [int , int ] = ...
96
- MISSING_VALUES : dict [str , int ] = ...
97
- NUMPY_TYPE_MAP : dict [str , str ] = ...
98
- RESERVED_WORDS : tuple [str , ...] = ...
99
78
def __init__ (self ) -> None : ...
100
79
101
80
class StataReader (StataParser , abc .Iterator ):
@@ -142,70 +121,19 @@ class StataReader(StataParser, abc.Iterator):
142
121
def value_labels (self ) -> dict [str , dict [float , str ]]: ...
143
122
144
123
class StataWriter (StataParser ):
145
- type_converters : dict [str , type [np .dtype ]] = ...
146
124
def __init__ (
147
125
self ,
148
126
fname : FilePath | WriteBuffer [bytes ],
149
127
data : DataFrame ,
150
- convert_dates : dict [Hashable , str ] | None = ...,
128
+ convert_dates : dict [HashableT , StataDateFormat ] | None = ...,
151
129
write_index : bool = ...,
152
130
byteorder : str | None = ...,
153
131
time_stamp : datetime .datetime | None = ...,
154
132
data_label : str | None = ...,
155
- variable_labels : dict [Hashable , str ] | None = ...,
133
+ variable_labels : dict [HashableT , str ] | None = ...,
156
134
compression : CompressionOptions = ...,
157
135
storage_options : StorageOptions = ...,
158
136
* ,
159
- value_labels : dict [Hashable , dict [float , str ]] | None = ...,
137
+ value_labels : dict [HashableT , dict [float , str ]] | None = ...,
160
138
) -> None : ...
161
139
def write_file (self ) -> None : ...
162
-
163
- class StataStrLWriter :
164
- df : DataFrame = ...
165
- columns : Sequence [str ] = ...
166
- def __init__ (
167
- self ,
168
- df : DataFrame ,
169
- columns : Sequence [str ],
170
- version : int = ...,
171
- byteorder : str | None = ...,
172
- ) -> None : ...
173
- def generate_table (self ) -> tuple [dict [str , tuple [int , int ]], DataFrame ]: ...
174
- def generate_blob (self , gso_table : dict [str , tuple [int , int ]]) -> bytes : ...
175
-
176
- class StataWriter117 (StataWriter ):
177
- def __init__ (
178
- self ,
179
- fname : FilePath | WriteBuffer [bytes ],
180
- data : DataFrame ,
181
- convert_dates : dict [Hashable , str ] | None = ...,
182
- write_index : bool = ...,
183
- byteorder : str | None = ...,
184
- time_stamp : datetime .datetime | None = ...,
185
- data_label : str | None = ...,
186
- variable_labels : dict [Hashable , str ] | None = ...,
187
- convert_strl : Sequence [Hashable ] | None = ...,
188
- compression : CompressionOptions = ...,
189
- storage_options : StorageOptions = ...,
190
- * ,
191
- value_labels : dict [Hashable , dict [float , str ]] | None = ...,
192
- ) -> None : ...
193
-
194
- class StataWriterUTF8 (StataWriter117 ):
195
- def __init__ (
196
- self ,
197
- fname : FilePath | WriteBuffer [bytes ],
198
- data : DataFrame ,
199
- convert_dates : dict [Hashable , str ] | None = ...,
200
- write_index : bool = ...,
201
- byteorder : str | None = ...,
202
- time_stamp : datetime .datetime | None = ...,
203
- data_label : str | None = ...,
204
- variable_labels : dict [Hashable , str ] | None = ...,
205
- convert_strl : Sequence [Hashable ] | None = ...,
206
- version : int | None = ...,
207
- compression : CompressionOptions = ...,
208
- storage_options : StorageOptions = ...,
209
- * ,
210
- value_labels : dict [Hashable , dict [float , str ]] | None = ...,
211
- ) -> None : ...
0 commit comments