Closed ShaharNaveh closed 4 years ago
Im taking:
[x] pandas/_libs/groupby.pyx
[x] pandas/_libs/hashing.pyx
[x] pandas/_libs/index.pyx
[x] pandas/_libs/internals.pyx
[x] pandas/_libs/interval.pyx
[x] pandas/_libs/lib.pyx
[x] pandas/_libs/ops.pyx
[x] pandas/_libs/parsers.pyx
[x] pandas/_libs/reduction.pyx
[x] pandas/_libs/sparse.pyx
[x] pandas/_libs/testing.pyx
[x] pandas/_libs/tslib.pyx
[x] pandas/_libs/window.pyx
I'll take:
to start, if that's alright!
Hi @MomIsBestFriend Can you recommend any tools for this conversion? A quick look gave me these:
I have no experience with either of them, but they could be very helpful here
Hello @SaturnFromTitan , I personally sometimes use pyupgrade but only when the file contain only a few outdated string formats in it. Then I look at the changes and fix if pyupgrade got something wrong.
When they're files with alot of occurrences I go for the "complex" ones manually (e.g '%.2f' % my_float
) and let it deal with the common ones, usually it gets it right.
Also, some of the changes will make the changed file non pep8 compatible, so there's a need to fix that as well, otherwise it will not pass the tests.
Will take next:
[x] pandas/compat/__init__.py
[x] pandas/compat/numpy/function.py
[x] pandas/compat/numpy/__init__.py
[x] pandas/compat/_optional.py
I'll take:
What are everyone's thoughts on tagging this as a good first issue
? It should apply to most of the files here. The changes that need to be made are usually only a few lines or so per file, and whoever is making the changes doesn't need to worry too much about affecting other parts of the code (since the end function performed is the same).
I'm picturing a setup similar to #28926.
f-string replacement placed on:
ref #29701
Will take next:
[x] pandas/_libs/tslibs/conversion.pyx
[x] pandas/_libs/tslibs/c_timestamp.pyx
[x] pandas/_libs/tslibs/fields.pyx
[x] pandas/_libs/tslibs/nattype.pyx
[x] pandas/_libs/tslibs/np_datetime.pyx
[x] pandas/_libs/tslibs/offsets.pyx
[x] pandas/_libs/tslibs/parsing.pyx
[x] pandas/_libs/tslibs/timestamps.pyx
[x] pandas/_libs/tslibs/timezones.pyx
[x] pandas/_libs/tslibs/tzconversion.pyx
I'll take
ref #29781
I'll take:
- [x] pandas/core/reshape/concat.py
- [x] pandas/core/reshape/melt.py
- [ ] pandas/core/reshape/merge.py
- [x] pandas/core/reshape/pivot.py
- [x] pandas/core/reshape/reshape.py
- [ ] pandas/core/reshape/tile.py
What are everyone's thoughts on tagging this as a
good first issue
? It should apply to most of the files here. The changes that need to be made are usually only a few lines or so per file, and whoever is making the changes doesn't need to worry too much about affecting other parts of the code (since the end function performed is the same).I'm picturing a setup similar to #28926.
Sure ive labelled accordingly. thanks
Taking next:
[x] pandas/io/msgpack/_packer.pyx
[x] pandas/io/msgpack/_unpacker.pyx
[x] pandas/io/sas/sas.pyx
Sorry I just noticed that you have asked to specify which files to work on. I just have been using
grep -n -R -e '%s' -e '%d' -e '.format(' --include=*.{py,pyx} pandas/
To find any old formatting. I apologize
Sorry I just noticed that you have asked to specify which files to work on. I just have been using
@ForTimeBeing That's why I edited the post, glad you noticed:)
can you post what you worked on? just in case someone searches the comments.
Sure, I took;
and under
.format still exists and shows in the grep search, but there are no literals to change to fstring. Not sure if there is another way to do it or keep as is but all literals are swapped to fstring now in that file.
.format still exists and shows in the grep search, but there are no literals to change to fstring. Not sure if there is another way to do it or keep as is but all literals are swapped to fstring now in that file.
@ForTimeBeing No problems:) thank you for the PR:)
I took
ref #29952
I'll take:
[x] ci/print_skipped.py
[x] doc/make.py
[x] doc/sphinxext/announce.py
[x] doc/sphinxext/contributors.py
Working on: 'pandas/core/dtypes/dtypes.py'
Took:
ref: #30116, #30135, #30363
I'll take:
I have problem with predefined strings. I found the solution but I'm not sure if it's the right one. Imagine the situation where you have predefined string like: THE_MESSAGE = "Message with arguments. Arg1: {arg1}, Arg2: {arg2}." Which is called with .format() like: THE_MESSAGE.format(arg1_str, arg2_str).
Could I rewrite this by using lambda function in a way described below? THE_MESSAGE = lambda arg1, arg2: f"Message with arguments. Arg1: {arg1}, Arg2: {arg2}."
and call it by THE_MESSAGE(arg1_str, arg2_str)?
I know that would work I'm not sure if it's the best way to approach this problem :)
I have problem with predefined strings.
I completely understand, As pep 498 explains:
Regular strings are concatenated at compile time, and f-strings are concatenated at run time.
We need to think of a way to remove the use of .format()
and use something else a string template.
The only thing I can think of at the moment is string.Template
from stdlib, but I really don't know.
@jbrockmendel Can you help us out?
@MomIsBestFriend do you thing that lambda function is an overkill for this?
@MomIsBestFriend i think this may be a case where living with a few .format
s is the way to go
@MomIsBestFriend do you thing that lambda function is an overkill for this?
I'm no way near an expert, please ask one of the developers.
took
ref #30120
took
ref #30121
took
ref #30124
I'll take
Edit: Taking:
[x] pandas/util/_decorators.py
[x] pandas/util/_depr_module.py
[x] pandas/util/_doctools.py
[x] pandas/util/_print_versions.py
[x] pandas/util/_test_decorators.py
[x] pandas/util/_tester.py
[x] pandas/util/testing.py
[x] pandas/util/_validators.py
I'll take
thanks!
I'll take:
pandas/tests/plotting/test_converter.py
pandas/tests/plotting/test_datetimelike.py
pandas/tests/plotting/test_series.py
I'll take
Hello, @MomIsBestFriend
pandas/tests/plotting/test_converter.py
pandas/tests/plotting/test_datetimelike.py
pandas/tests/plotting/test_series.py
Have been completed. Thank you.
Hello I can take
Thanks
Hello, I'll take
Thanks!
I took:
pandas/core/missing.py
pandas/core/nanops.py
pandas/tests/indexes/datetimes/test_partial_slicing.py
Link to my pr: https://github.com/pandas-dev/pandas/pull/30278
I'll work on:
Here because of the tag "good first issue"
I'll take:
[ ] pandas/io/sql.py
[ ] pandas/io/stata.py
Thanks!
I'll do:
i would like to take i just now did a pull request on it
Great, always wanted to chip in on Pandas. Will update when I know what I can fulfill in the next few weeks...
I can take pandas/_version.py
Jumping on:
I'll take pandas/io/formats/csvs.py
I'm taking:
Question: Is there an answer on whether old-school string formatting should remain in the API reference?
For example, in series.map()
:
It also accepts a function:
>>> s.map('I am a {}'.format)
0 I am a cat
1 I am a dog
2 I am a nan
3 I am a rabbit
dtype: object
Replacing this with an f-string example forces something like:
>>> s.map(lambda x: f'I am a {x}')
0 I am a cat
1 I am a dog
2 I am a nan
3 I am a rabbit
dtype: object
Which is not an exact replacement (f-string is not a function, I'm using the lambda to make it a function that replicates the net effect of 'I am a '.format() ), and raises some thorny issues about putting some not-best-practices in documentation.
For now, I am considering changing the documentation as out-of-scope, pending community decision on how to handle cases like this.
Already done (not sure by whom): pandas/tests/arrays/interval/test_ops.py
I'll also take
Question: Is there an answer on whether old-school string formatting should remain in the API reference?
cc @WillAyd @jreback
I don't know what you consider the "old-school string format" to be but .format
will have some use cases that f-strings don't cover (namely delayed parametrization) so sure that will still be around. I don't think we should have Py27 string format syntax anywhere though
I'lll take:
I'll take
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 #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:All of the above can also be used as a one liner:
Tip:
If you want to see the line number of the occurrence, replace the
-l
with-n
for example: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.