Skip to content

Replace old string formatting syntax with f-strings #29547

Closed
@ShaharNaveh

Description

@ShaharNaveh

Since we no longer support python 3.5, we can now use the new f-strings instead of the old .format() ( and obviously the % formatting).

Notes:

  • Don't forget to link this issue in your pull request's body message , simply paste this https://github.com/pandas-dev/pandas/issues/29547 in your pull request's body message.

  • If any of your changed files are related to Replace "foo!r" to "repr(foo)" syntax #29886 , please make sure to link your pull request to that issue as well, simply paste this https://github.com/pandas-dev/pandas/issues/29886 in your pull request's body message as well.

  • Please comment what you are planning to work on, so we won't do double work.

  • If a file/files that should be marked as done, is not marked, please comment letting me know.


To check what files still needs to be fixed in the pandas directory:

grep -l -R '%s'  --include=*.{py,pyx} pandas/
grep -l -R '%d' --include=*.{py,pyx} pandas/
grep -l -R '\.format(' --include=*.{py,pyx} pandas/

All of the above can also be used as a one liner:

grep -l -R -e '%s' -e '%d' -e '\.format(' --include=*.{py,pyx} pandas/
Tip:

If you want to see the line number of the occurrence, replace the -l with -n
for example:

grep -n -R '%s' --include=*.{py,pyx} pandas/

The current list is:

  • pandas/compat/pickle_compat.py

  • pandas/_config/config.py

  • pandas/core/arrays/datetimelike.py

  • pandas/core/arrays/datetimes.py

  • pandas/core/arrays/integer.py

  • pandas/core/arrays/period.py

  • pandas/core/computation/pytables.py

  • pandas/core/config_init.py

  • pandas/core/frame.py

  • pandas/core/generic.py

  • pandas/core/groupby/generic.py

  • pandas/core/groupby/groupby.py

  • pandas/core/indexes/base.py

  • pandas/core/indexes/multi.py

  • pandas/core/indexes/range.py

  • pandas/core/ops/docstrings.py

  • pandas/core/ops/__init__.py

  • pandas/core/reshape/merge.py

  • pandas/core/tools/datetimes.py

  • pandas/io/formats/css.py

  • pandas/io/formats/excel.py

  • pandas/io/formats/format.py

  • pandas/io/formats/html.py

  • pandas/io/formats/info.py

  • pandas/io/formats/latex.py

  • pandas/io/formats/printing.py

  • pandas/io/formats/style.py

  • pandas/io/parsers.py

  • pandas/io/pytables.py

  • pandas/io/sas/sas_xport.py

  • pandas/io/stata.py

  • pandas/_libs/tslibs/c_timestamp.pyx

  • pandas/_libs/tslibs/frequencies.pyx

  • pandas/_libs/tslibs/parsing.pyx

  • pandas/_libs/tslibs/period.pyx

  • pandas/_libs/tslibs/strptime.pyx

  • pandas/_libs/tslibs/timedeltas.pyx

  • pandas/plotting/_matplotlib/converter.py

  • pandas/tests/arrays/categorical/test_operators.py

  • pandas/tests/arrays/test_datetimelike.py

  • pandas/tests/dtypes/test_dtypes.py

  • pandas/tests/extension/base/setitem.py

  • pandas/tests/frame/test_constructors.py

  • pandas/tests/frame/test_missing.py

  • pandas/tests/frame/test_to_csv.py

  • pandas/tests/groupby/aggregate/test_other.py

  • pandas/tests/indexes/datetimes/test_date_range.py

  • pandas/tests/indexes/datetimes/test_datetime.py

  • pandas/tests/indexes/datetimes/test_formats.py

  • pandas/tests/indexes/datetimes/test_partial_slicing.py

  • pandas/tests/indexes/interval/test_constructors.py

  • pandas/tests/indexes/interval/test_interval.py

  • pandas/tests/indexes/multi/test_format.py

  • pandas/tests/indexes/period/test_formats.py

  • pandas/tests/indexes/test_base.py

  • pandas/tests/indexes/timedeltas/test_timedelta.py

  • pandas/tests/indexing/test_categorical.py

  • pandas/tests/indexing/test_coercion.py

  • pandas/tests/io/excel/test_openpyxl.py

  • pandas/tests/io/excel/test_writers.py

  • pandas/tests/io/formats/test_format.py

  • pandas/tests/io/formats/test_printing.py

  • pandas/tests/io/formats/test_style.py

  • pandas/tests/io/formats/test_to_csv.py

  • pandas/tests/io/formats/test_to_html.py

  • pandas/tests/io/formats/test_to_latex.py

  • pandas/tests/io/parser/test_compression.py

  • pandas/tests/io/parser/test_encoding.py

  • pandas/tests/io/parser/test_header.py

  • pandas/tests/io/parser/test_parse_dates.py

  • pandas/tests/io/parser/test_usecols.py

  • pandas/tests/io/test_html.py

  • pandas/tests/io/test_sql.py

  • pandas/tests/io/test_stata.py

  • pandas/tests/reductions/test_reductions.py

  • pandas/tests/reshape/test_concat.py

  • pandas/tests/reshape/test_melt.py

  • pandas/tests/scalar/period/test_period.py

  • pandas/tests/scalar/timedelta/test_timedelta.py

  • pandas/tests/scalar/timestamp/test_constructors.py

  • pandas/tests/series/indexing/test_numeric.py

  • pandas/tests/series/indexing/test_take.py

  • pandas/tests/series/indexing/test_where.py

  • pandas/tests/series/methods/test_rename.py

  • pandas/tests/series/test_api.py

  • pandas/tests/series/test_constructors.py

  • pandas/tests/series/test_datetime_values.py

  • pandas/tests/series/test_repr.py

  • pandas/tests/test_strings.py

  • pandas/tests/tools/test_to_datetime.py

  • pandas/tests/tseries/holiday/test_calendar.py

  • pandas/tests/tseries/holiday/test_holiday.py

  • pandas/tests/tslibs/test_parsing.py

  • pandas/tests/util/test_assert_frame_equal.py

  • pandas/tseries/frequencies.py

  • pandas/util/_decorators.py

  • pandas/util/_test_decorators.py

  • pandas/util/_validators.py

  • pandas/_version.py


NOTE:

The list may change as files are moved/renamed constantly.


Inhereted files and commands from this PR.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions