@@ -3,9 +3,9 @@ import datetime
33from io import BytesIO
44from types import TracebackType
55from typing import (
6- Hashable ,
76 Literal ,
87 Sequence ,
8+ overload ,
99)
1010
1111import numpy as np
@@ -18,10 +18,12 @@ from pandas._typing import (
1818 FilePath ,
1919 HashableT ,
2020 ReadBuffer ,
21+ StataDateFormat ,
2122 StorageOptions ,
2223 WriteBuffer ,
2324)
2425
26+ @overload
2527def read_stata (
2628 path : FilePath | ReadBuffer [bytes ],
2729 convert_dates : bool = ...,
@@ -32,70 +34,47 @@ def read_stata(
3234 columns : list [HashableT ] | None = ...,
3335 order_categoricals : bool = ...,
3436 chunksize : int | None = ...,
35- iterator : bool = ...,
37+ * ,
38+ iterator : Literal [True ],
3639 compression : CompressionOptions = ...,
3740 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 : ...
4272
4373class PossiblePrecisionLoss (Warning ): ...
44-
45- precision_loss_doc : str
46-
4774class ValueLabelTypeMismatch (Warning ): ...
48-
49- value_label_mismatch_doc : str
50-
5175class InvalidColumnName (Warning ): ...
5276
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-
8677class 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 , ...] = ...
9978 def __init__ (self ) -> None : ...
10079
10180class StataReader (StataParser , abc .Iterator ):
@@ -142,70 +121,19 @@ class StataReader(StataParser, abc.Iterator):
142121 def value_labels (self ) -> dict [str , dict [float , str ]]: ...
143122
144123class StataWriter (StataParser ):
145- type_converters : dict [str , type [np .dtype ]] = ...
146124 def __init__ (
147125 self ,
148126 fname : FilePath | WriteBuffer [bytes ],
149127 data : DataFrame ,
150- convert_dates : dict [Hashable , str ] | None = ...,
128+ convert_dates : dict [HashableT , StataDateFormat ] | None = ...,
151129 write_index : bool = ...,
152130 byteorder : str | None = ...,
153131 time_stamp : datetime .datetime | None = ...,
154132 data_label : str | None = ...,
155- variable_labels : dict [Hashable , str ] | None = ...,
133+ variable_labels : dict [HashableT , str ] | None = ...,
156134 compression : CompressionOptions = ...,
157135 storage_options : StorageOptions = ...,
158136 * ,
159- value_labels : dict [Hashable , dict [float , str ]] | None = ...,
137+ value_labels : dict [HashableT , dict [float , str ]] | None = ...,
160138 ) -> None : ...
161139 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