Skip to content

Commit f5c8d61

Browse files
Merge pull request #52 from VirtusLab/fix_from_dict
Add tests and modify from_dict DataFrame method
2 parents e5e4be9 + d2b208a commit f5c8d61

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def list_packages(source_path: str = src_path) -> None:
2121
setup(
2222
name="pandas-stubs",
2323
package_dir={"": src_path},
24-
version="1.1.0.9",
24+
version="1.1.0.10",
2525
description="Type annotations for Pandas",
2626
long_description=(open("README.md").read()
2727
if os.path.exists("README.md") else ""),

tests/snippets/test_frame.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,3 +501,12 @@ def test_types_resample() -> None:
501501
df.resample('M', on='date')
502502
# origin and offset params added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
503503
df.resample('20min', origin='epoch', offset=pd.Timedelta(2, 'minutes'), on='date')
504+
505+
506+
def test_types_from_dict() -> None:
507+
pd.DataFrame.from_dict({'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']})
508+
pd.DataFrame.from_dict({1: [3, 2, 1, 0], 2: ['a', 'b', 'c', 'd']})
509+
pd.DataFrame.from_dict({'a': {1: 2}, 'b': {3: 4, 1: 4}}, orient="index")
510+
pd.DataFrame.from_dict({'a': {'row1': 2}, 'b': {'row2': 4, 'row1': 4}})
511+
pd.DataFrame.from_dict({'a': (1, 2, 3), 'b': (2, 4, 5)})
512+
pd.DataFrame.from_dict(data={'col_1': {'a': 1}, 'col_2': {'a': 1, 'b': 2}}, orient="columns")

third_party/3/pandas/core/frame.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class DataFrame(NDFrame):
9292
def itertuples(self, index: bool = ..., name: str = ...) -> Iterable[Tuple[Any, ...]]: ...
9393
def dot(self, other: Union[FrameOrSeries, ArrayLike]) -> FrameOrSeries: ...
9494
@classmethod
95-
def from_dict(cls: Any, data: Dict[str, Union[AnyArrayLike, Series, Dict[Column, Dtype]]], orient: Orientation = ..., dtype: Optional[Dtype] = ..., columns: Optional[Sequence[str]] = ...) -> DataFrame: ...
95+
def from_dict(cls: Any, data: Dict[Union[Label, Column], Union[Union[AnyArrayLike, Iterable[Any]], Dict[Union[Label, Column], Any]]], orient: Orientation = ..., dtype: Optional[Dtype] = ..., columns: Optional[Sequence[str]] = ...) -> DataFrame: ...
9696
def to_numpy(self, dtype: Union[str, np.dtype] = ..., copy: bool = ..., na_value: Optional[Any] = ...) -> np.ndarray: ...
9797
def to_dict(self, orient: ExportOrientation = ..., into: Type[Mapping[Column, Any]] = ...) -> Union[Mapping[Column, Any], List[Any]]: ...
9898
def to_gbq(self, destination_table: str, project_id: Optional[str] = ..., chunksize: Optional[int] = ..., reauth: bool = ..., if_exists: IfExistStrategy = ..., auth_local_webserver: bool = ..., table_schema: Optional[List[Dict[str, Any]]] = ..., location: Optional[str] = ..., progress_bar: bool = ..., credentials: Optional[GoogleCredentials] = ...) -> None: ...

0 commit comments

Comments
 (0)