Skip to content

Commit 59b5dc2

Browse files
committed
linting issues etc.
1 parent 06d72d3 commit 59b5dc2

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

doc/source/whatsnew/v1.1.0.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ These methods allow creating a ``string`` Series from arbitrary ``Series`` or ``
4444
'state_name': ['California', 'Texas', 'Florida'],
4545
'state_abbreviation': ['CA', 'TX', 'FL'],
4646
'population': [39_512_223, 28_995_881, 21_477_737],
47-
}, index=[1, 2, 3])
47+
}, index=[1, 2, 3])
4848
df
4949
ser = df["population"]
50-
5150
df.format("{state_name} ({state_abbreviation}): {population:,}")
52-
5351
ser.format("Population: {population:,}")
5452
5553
The output Series will always have dtype :class:`StringDtype`.
@@ -59,7 +57,6 @@ Formatting using positional arguments is also possible (``positional_only=True``
5957
.. ipython:: python
6058
6159
df.format("{} ({}): {:,}", positional_only=True)
62-
6360
ser.format("Population: {:,}", positional_only=True)
6461
6562

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3749,7 +3749,7 @@ def format(
37493749
self,
37503750
format: str,
37513751
name: Optional[str] = None,
3752-
positional_only: bool = False,
3752+
positional_only: bool_t = False,
37533753
how_na: str = "any",
37543754
) -> "Series":
37553755

pandas/core/strings.py

+17-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22
from functools import wraps
33
import re
44
import textwrap
5-
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Pattern, Type, Union
5+
from typing import (
6+
TYPE_CHECKING,
7+
Any,
8+
Callable,
9+
Dict,
10+
List,
11+
Optional,
12+
Pattern,
13+
Type,
14+
Union,
15+
)
616
import warnings
717

818
import numpy as np
@@ -245,7 +255,7 @@ def g(x):
245255
def str_format(
246256
arr,
247257
format: str,
248-
name: str = None,
258+
name: Optional[str] = None,
249259
positional_only: bool = False,
250260
how_na: str = "any",
251261
) -> "Series":
@@ -254,16 +264,16 @@ def str_format(
254264
255265
Parameters
256266
----------
257-
arr: DataFrame or Series
267+
arr : DataFrame or Series
258268
The values to format.
259269
format : str
260270
format string.
261-
name: Label, optional
271+
name : Label, optional
262272
The name of the returned Series.
263-
positional_only: bool, default False
273+
positional_only : bool, default False
264274
If True, only allow positional parameters (i.e. allow "{}", but not "{key}").
265275
Setting to ``True`` will improve performance.
266-
how_na: str, one of {"all", "any"}, default "any"
276+
how_na : str, one of {"all", "any"}, default "any"
267277
If "all", return ``NA`` if all values in row are nan values.
268278
If "any", return ``NA`` if at least one of the values in row is a nan value.
269279
@@ -294,7 +304,7 @@ def str_format(
294304
3 Population: 21,477,737
295305
dtype: string
296306
297-
>>> df.format("{} ({}): {:,}")
307+
>>> df.format("{} ({}): {:,}")
298308
1 California (CA): 39,512,223
299309
2 Texas (TX): 28,995,881
300310
3 Florida (FL): 21,477,737

0 commit comments

Comments
 (0)