Skip to content

Commit e897350

Browse files
LarWongMarcoGorelli
authored andcommitted
TYP overload fillna pandas-dev#40737 (pandas-dev#40887)
* TYP: Added overloads for fillna() in frame.py and series.py * TYP: Added overloads for fillna() in frame.py and series.py pandas-dev#40737 * TYP: Added fillna() overloads to generic.py pandas-dev#40727 * TYP: removed generic overloads pandas-dev#40737 * fixed redundant cast error * reverting prior changes * remove cast again * removed unnecessary overloads in frame.py and series.py * fixed overloads * reverted value typing * remove extra types (lets keep this to overloads) Co-authored-by: Marco Gorelli <[email protected]>
1 parent 3e5874f commit e897350

File tree

3 files changed

+230
-3
lines changed

3 files changed

+230
-3
lines changed

pandas/core/frame.py

+115
Original file line numberDiff line numberDiff line change
@@ -5007,6 +5007,121 @@ def rename(
50075007
errors=errors,
50085008
)
50095009

5010+
@overload
5011+
def fillna(
5012+
self,
5013+
value=...,
5014+
method: str | None = ...,
5015+
axis: Axis | None = ...,
5016+
inplace: Literal[False] = ...,
5017+
limit=...,
5018+
downcast=...,
5019+
) -> DataFrame:
5020+
...
5021+
5022+
@overload
5023+
def fillna(
5024+
self,
5025+
value,
5026+
method: str | None,
5027+
axis: Axis | None,
5028+
inplace: Literal[True],
5029+
limit=...,
5030+
downcast=...,
5031+
) -> None:
5032+
...
5033+
5034+
@overload
5035+
def fillna(
5036+
self,
5037+
*,
5038+
inplace: Literal[True],
5039+
limit=...,
5040+
downcast=...,
5041+
) -> None:
5042+
...
5043+
5044+
@overload
5045+
def fillna(
5046+
self,
5047+
value,
5048+
*,
5049+
inplace: Literal[True],
5050+
limit=...,
5051+
downcast=...,
5052+
) -> None:
5053+
...
5054+
5055+
@overload
5056+
def fillna(
5057+
self,
5058+
*,
5059+
method: str | None,
5060+
inplace: Literal[True],
5061+
limit=...,
5062+
downcast=...,
5063+
) -> None:
5064+
...
5065+
5066+
@overload
5067+
def fillna(
5068+
self,
5069+
*,
5070+
axis: Axis | None,
5071+
inplace: Literal[True],
5072+
limit=...,
5073+
downcast=...,
5074+
) -> None:
5075+
...
5076+
5077+
@overload
5078+
def fillna(
5079+
self,
5080+
*,
5081+
method: str | None,
5082+
axis: Axis | None,
5083+
inplace: Literal[True],
5084+
limit=...,
5085+
downcast=...,
5086+
) -> None:
5087+
...
5088+
5089+
@overload
5090+
def fillna(
5091+
self,
5092+
value,
5093+
*,
5094+
axis: Axis | None,
5095+
inplace: Literal[True],
5096+
limit=...,
5097+
downcast=...,
5098+
) -> None:
5099+
...
5100+
5101+
@overload
5102+
def fillna(
5103+
self,
5104+
value,
5105+
method: str | None,
5106+
*,
5107+
inplace: Literal[True],
5108+
limit=...,
5109+
downcast=...,
5110+
) -> None:
5111+
...
5112+
5113+
@overload
5114+
def fillna(
5115+
self,
5116+
value=...,
5117+
method: str | None = ...,
5118+
axis: Axis | None = ...,
5119+
inplace: bool = ...,
5120+
limit=...,
5121+
downcast=...,
5122+
) -> DataFrame | None:
5123+
...
5124+
50105125
@doc(NDFrame.fillna, **_shared_doc_kwargs)
50115126
def fillna(
50125127
self,

pandas/core/series.py

+115
Original file line numberDiff line numberDiff line change
@@ -4581,6 +4581,121 @@ def drop(
45814581
errors=errors,
45824582
)
45834583

4584+
@overload
4585+
def fillna(
4586+
self,
4587+
value=...,
4588+
method: str | None = ...,
4589+
axis: Axis | None = ...,
4590+
inplace: Literal[False] = ...,
4591+
limit=...,
4592+
downcast=...,
4593+
) -> Series:
4594+
...
4595+
4596+
@overload
4597+
def fillna(
4598+
self,
4599+
value,
4600+
method: str | None,
4601+
axis: Axis | None,
4602+
inplace: Literal[True],
4603+
limit=...,
4604+
downcast=...,
4605+
) -> None:
4606+
...
4607+
4608+
@overload
4609+
def fillna(
4610+
self,
4611+
*,
4612+
inplace: Literal[True],
4613+
limit=...,
4614+
downcast=...,
4615+
) -> None:
4616+
...
4617+
4618+
@overload
4619+
def fillna(
4620+
self,
4621+
value,
4622+
*,
4623+
inplace: Literal[True],
4624+
limit=...,
4625+
downcast=...,
4626+
) -> None:
4627+
...
4628+
4629+
@overload
4630+
def fillna(
4631+
self,
4632+
*,
4633+
method: str | None,
4634+
inplace: Literal[True],
4635+
limit=...,
4636+
downcast=...,
4637+
) -> None:
4638+
...
4639+
4640+
@overload
4641+
def fillna(
4642+
self,
4643+
*,
4644+
axis: Axis | None,
4645+
inplace: Literal[True],
4646+
limit=...,
4647+
downcast=...,
4648+
) -> None:
4649+
...
4650+
4651+
@overload
4652+
def fillna(
4653+
self,
4654+
*,
4655+
method: str | None,
4656+
axis: Axis | None,
4657+
inplace: Literal[True],
4658+
limit=...,
4659+
downcast=...,
4660+
) -> None:
4661+
...
4662+
4663+
@overload
4664+
def fillna(
4665+
self,
4666+
value,
4667+
*,
4668+
axis: Axis | None,
4669+
inplace: Literal[True],
4670+
limit=...,
4671+
downcast=...,
4672+
) -> None:
4673+
...
4674+
4675+
@overload
4676+
def fillna(
4677+
self,
4678+
value,
4679+
method: str | None,
4680+
*,
4681+
inplace: Literal[True],
4682+
limit=...,
4683+
downcast=...,
4684+
) -> None:
4685+
...
4686+
4687+
@overload
4688+
def fillna(
4689+
self,
4690+
value=...,
4691+
method: str | None = ...,
4692+
axis: Axis | None = ...,
4693+
inplace: bool = ...,
4694+
limit=...,
4695+
downcast=...,
4696+
) -> Series | None:
4697+
...
4698+
45844699
@doc(NDFrame.fillna, **_shared_doc_kwargs)
45854700
def fillna(
45864701
self,

pandas/core/strings/object_array.py

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
Pattern,
66
Set,
77
Union,
8-
cast,
98
)
109
import unicodedata
1110
import warnings
@@ -371,9 +370,7 @@ def _str_get_dummies(self, sep="|"):
371370
try:
372371
arr = sep + arr + sep
373372
except TypeError:
374-
arr = cast(Series, arr)
375373
arr = sep + arr.astype(str) + sep
376-
arr = cast(Series, arr)
377374

378375
tags: Set[str] = set()
379376
for ts in Series(arr).str.split(sep):

0 commit comments

Comments
 (0)