Skip to content

Commit

Permalink
Merge pull request #52 from VirtusLab/fix_from_dict
Browse files Browse the repository at this point in the history
Add tests and modify from_dict DataFrame method
  • Loading branch information
joannasendorek authored Jun 16, 2021
2 parents e5e4be9 + d2b208a commit f5c8d61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def list_packages(source_path: str = src_path) -> None:
setup(
name="pandas-stubs",
package_dir={"": src_path},
version="1.1.0.9",
version="1.1.0.10",
description="Type annotations for Pandas",
long_description=(open("README.md").read()
if os.path.exists("README.md") else ""),
Expand Down
9 changes: 9 additions & 0 deletions tests/snippets/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,12 @@ def test_types_resample() -> None:
df.resample('M', on='date')
# origin and offset params added in 1.1.0 https://pandas.pydata.org/docs/whatsnew/v1.1.0.html
df.resample('20min', origin='epoch', offset=pd.Timedelta(2, 'minutes'), on='date')


def test_types_from_dict() -> None:
pd.DataFrame.from_dict({'col_1': [3, 2, 1, 0], 'col_2': ['a', 'b', 'c', 'd']})
pd.DataFrame.from_dict({1: [3, 2, 1, 0], 2: ['a', 'b', 'c', 'd']})
pd.DataFrame.from_dict({'a': {1: 2}, 'b': {3: 4, 1: 4}}, orient="index")
pd.DataFrame.from_dict({'a': {'row1': 2}, 'b': {'row2': 4, 'row1': 4}})
pd.DataFrame.from_dict({'a': (1, 2, 3), 'b': (2, 4, 5)})
pd.DataFrame.from_dict(data={'col_1': {'a': 1}, 'col_2': {'a': 1, 'b': 2}}, orient="columns")
2 changes: 1 addition & 1 deletion third_party/3/pandas/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DataFrame(NDFrame):
def itertuples(self, index: bool = ..., name: str = ...) -> Iterable[Tuple[Any, ...]]: ...
def dot(self, other: Union[FrameOrSeries, ArrayLike]) -> FrameOrSeries: ...
@classmethod
def from_dict(cls: Any, data: Dict[str, Union[AnyArrayLike, Series, Dict[Column, Dtype]]], orient: Orientation = ..., dtype: Optional[Dtype] = ..., columns: Optional[Sequence[str]] = ...) -> DataFrame: ...
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: ...
def to_numpy(self, dtype: Union[str, np.dtype] = ..., copy: bool = ..., na_value: Optional[Any] = ...) -> np.ndarray: ...
def to_dict(self, orient: ExportOrientation = ..., into: Type[Mapping[Column, Any]] = ...) -> Union[Mapping[Column, Any], List[Any]]: ...
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: ...
Expand Down

0 comments on commit f5c8d61

Please sign in to comment.