From 194d5a7302c1fad200b0cb5d189797e3bed80d45 Mon Sep 17 00:00:00 2001 From: clement Date: Thu, 19 Mar 2020 10:51:47 +0100 Subject: [PATCH 01/23] Updating capitalization in folder doc/source/reference --- doc/source/reference/arrays.rst | 2 +- doc/source/reference/frame.rst | 2 +- doc/source/reference/indexing.rst | 2 +- doc/source/reference/series.rst | 2 +- doc/source/reference/window.rst | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index c71350ecd73b3..1725c415fa020 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -3,7 +3,7 @@ .. _api.arrays: ============= -Pandas arrays +pandas arrays ============= .. currentmodule:: pandas diff --git a/doc/source/reference/frame.rst b/doc/source/reference/frame.rst index b326bbb5a465e..cf81540a77d11 100644 --- a/doc/source/reference/frame.rst +++ b/doc/source/reference/frame.rst @@ -251,7 +251,7 @@ Combining / joining / merging DataFrame.merge DataFrame.update -Time series-related +Time Series-related ~~~~~~~~~~~~~~~~~~~ .. autosummary:: :toctree: api/ diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index ab6ea5aea6c61..ba12c19763605 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -328,7 +328,7 @@ DatetimeIndex DatetimeIndex -Time/Date components +Time/date components ~~~~~~~~~~~~~~~~~~~~ .. autosummary:: :toctree: api/ diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index 1a69fa076dbf0..aa21ecdb54c7a 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -249,7 +249,7 @@ Combining / joining / merging Series.replace Series.update -Time series-related +Time Series-related ------------------- .. autosummary:: :toctree: api/ diff --git a/doc/source/reference/window.rst b/doc/source/reference/window.rst index 3db1aa12a4275..570a0607ebd21 100644 --- a/doc/source/reference/window.rst +++ b/doc/source/reference/window.rst @@ -75,7 +75,7 @@ Exponentially-weighted moving window functions EWM.corr EWM.cov -Window Indexer +Window indexer -------------- .. currentmodule:: pandas From 9da1e8a93c336f315162ab49f1258670e624df22 Mon Sep 17 00:00:00 2001 From: clement Date: Fri, 20 Mar 2020 12:28:34 +0100 Subject: [PATCH 02/23] Add folder doc/source/reference in ci code checking in ci/code_checks.sh L 330 --- ci/code_checks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index e6a761b91f353..630bf21798a2e 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -327,7 +327,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then RET=$(($RET + $?)) ; echo $MSG "DONE" MSG='Validate correct capitalization among titles in documentation' ; echo $MSG - $BASE_DIR/scripts/validate_rst_title_capitalization.py $BASE_DIR/doc/source/development/contributing.rst + $BASE_DIR/scripts/validate_rst_title_capitalization.py $BASE_DIR/doc/source/development/contributing.rst $BASE_DIR/doc/source/reference RET=$(($RET + $?)) ; echo $MSG "DONE" fi From 55587f711924cd1bc9a4401e11aaeac9ab9fd9b3 Mon Sep 17 00:00:00 2001 From: clement Date: Fri, 20 Mar 2020 17:41:25 +0100 Subject: [PATCH 03/23] Modification of validate_rst_title_capitalization.py script --- scripts/validate_rst_title_capitalization.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 17752134e5049..f1f224748d333 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -72,7 +72,19 @@ def correct_title_capitalization(title: str) -> str: # Strip all non-word characters from the beginning of the title to the # first word character. - correct_title: str = re.sub(r"^\W*", "", title).capitalize() + correct_title: str = re.sub(r"^\W*", "", title) + + if re.search(r'((?:[A-Z]\w*){2,})', correct_title): + list_words = correct_title.split(' ') + if list_words[0][0].islower(): list_words[0].capitalize() + for idx in range(1, len(list_words)): + if not re.search(r'((?:[A-Z]\w*){2,})', list_words[idx]): + list_words[idx] = list_words[idx].lower() + + correct_title = " ".join(list_words) + + else: + correct_title = correct_title.capitalize() # Remove a URL from the title. We do this because words in a URL must # stay lowercase, even if they are a capitalization exception. From 048fb783f299d3238dbe113744fa2d20b12ec3c3 Mon Sep 17 00:00:00 2001 From: clement Date: Fri, 20 Mar 2020 18:44:34 +0100 Subject: [PATCH 04/23] Modify validate_rst_title_capitalization.py script to take into account words with multiple capital letters --- scripts/validate_rst_title_capitalization.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index f1f224748d333..e6be7ab9f1055 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -74,9 +74,14 @@ def correct_title_capitalization(title: str) -> str: # first word character. correct_title: str = re.sub(r"^\W*", "", title) + #Take into consideration words with multiple capital letters + #Such as DataFrame or PeriodIndex or IO to not lower them. + #Lower the other words if re.search(r'((?:[A-Z]\w*){2,})', correct_title): - list_words = correct_title.split(' ') - if list_words[0][0].islower(): list_words[0].capitalize() + list_words: List[str] = correct_title.split(' ') + if correct_title[0].islower(): + list_words[0].replace(correct_title[0], correct_title[0].upper()) + for idx in range(1, len(list_words)): if not re.search(r'((?:[A-Z]\w*){2,})', list_words[idx]): list_words[idx] = list_words[idx].lower() From d1ae9eacaf2633183c7f2e4b7b3317ffc527c1a5 Mon Sep 17 00:00:00 2001 From: clement Date: Fri, 20 Mar 2020 19:05:06 +0100 Subject: [PATCH 05/23] remove stylistic errors in comment section L:77,78,79 --- scripts/validate_rst_title_capitalization.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index e6be7ab9f1055..2aec4be6b301e 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -74,9 +74,9 @@ def correct_title_capitalization(title: str) -> str: # first word character. correct_title: str = re.sub(r"^\W*", "", title) - #Take into consideration words with multiple capital letters - #Such as DataFrame or PeriodIndex or IO to not lower them. - #Lower the other words + # Take into consideration words with multiple capital letters + # Such as DataFrame or PeriodIndex or IO to not lower them. + # Lower the other words if re.search(r'((?:[A-Z]\w*){2,})', correct_title): list_words: List[str] = correct_title.split(' ') if correct_title[0].islower(): From 83280b73bbb5090d10b62164ec718e75170712ec Mon Sep 17 00:00:00 2001 From: clement Date: Sun, 22 Mar 2020 21:49:14 +0100 Subject: [PATCH 06/23] Modify validate_rst_title_capitalization.py script --- scripts/validate_rst_title_capitalization.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 17752134e5049..2aec4be6b301e 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -72,7 +72,24 @@ def correct_title_capitalization(title: str) -> str: # Strip all non-word characters from the beginning of the title to the # first word character. - correct_title: str = re.sub(r"^\W*", "", title).capitalize() + correct_title: str = re.sub(r"^\W*", "", title) + + # Take into consideration words with multiple capital letters + # Such as DataFrame or PeriodIndex or IO to not lower them. + # Lower the other words + if re.search(r'((?:[A-Z]\w*){2,})', correct_title): + list_words: List[str] = correct_title.split(' ') + if correct_title[0].islower(): + list_words[0].replace(correct_title[0], correct_title[0].upper()) + + for idx in range(1, len(list_words)): + if not re.search(r'((?:[A-Z]\w*){2,})', list_words[idx]): + list_words[idx] = list_words[idx].lower() + + correct_title = " ".join(list_words) + + else: + correct_title = correct_title.capitalize() # Remove a URL from the title. We do this because words in a URL must # stay lowercase, even if they are a capitalization exception. From 937b5df311c6e60c4be0359cef3ea5e86d87dfbf Mon Sep 17 00:00:00 2001 From: clement Date: Sun, 22 Mar 2020 22:23:08 +0100 Subject: [PATCH 07/23] modify script following tests --- scripts/validate_rst_title_capitalization.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 2aec4be6b301e..0cd0a9b40f661 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -10,12 +10,11 @@ """ import argparse -import sys -import re -import os -from typing import Tuple, Generator, List import glob - +import os +import re +import sys +from typing import Generator, List, Tuple CAPITALIZATION_EXCEPTIONS = { "pandas", From 589b0fec81d96a4a858c4dcf34296f0abf9ac24e Mon Sep 17 00:00:00 2001 From: clement Date: Mon, 23 Mar 2020 00:28:51 +0100 Subject: [PATCH 08/23] Modify second time following style checking --- scripts/validate_rst_title_capitalization.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 0cd0a9b40f661..783e5dab5d677 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -76,13 +76,13 @@ def correct_title_capitalization(title: str) -> str: # Take into consideration words with multiple capital letters # Such as DataFrame or PeriodIndex or IO to not lower them. # Lower the other words - if re.search(r'((?:[A-Z]\w*){2,})', correct_title): - list_words: List[str] = correct_title.split(' ') + if re.search(r"((?:[A-Z]\w*){2,})", correct_title): + list_words: List[str] = correct_title.split(" ") if correct_title[0].islower(): list_words[0].replace(correct_title[0], correct_title[0].upper()) for idx in range(1, len(list_words)): - if not re.search(r'((?:[A-Z]\w*){2,})', list_words[idx]): + if not re.search(r"((?:[A-Z]\w*){2,})", list_words[idx]): list_words[idx] = list_words[idx].lower() correct_title = " ".join(list_words) From e71cffde5deab8189a29c33661980ffbf41bef12 Mon Sep 17 00:00:00 2001 From: clement Date: Mon, 23 Mar 2020 18:51:37 +0100 Subject: [PATCH 09/23] Commit to update capitalization in folder doc/source/reference and to add elements to exceptions's set in scripts/validate_rst_title_capitalization.py --- doc/source/reference/arrays.rst | 2 +- doc/source/reference/frame.rst | 2 +- doc/source/reference/indexing.rst | 2 +- doc/source/reference/series.rst | 4 +- doc/source/reference/window.rst | 2 +- scripts/validate_rst_title_capitalization.py | 82 ++++++++++++++------ 6 files changed, 66 insertions(+), 28 deletions(-) diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index c71350ecd73b3..1725c415fa020 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -3,7 +3,7 @@ .. _api.arrays: ============= -Pandas arrays +pandas arrays ============= .. currentmodule:: pandas diff --git a/doc/source/reference/frame.rst b/doc/source/reference/frame.rst index b326bbb5a465e..cf81540a77d11 100644 --- a/doc/source/reference/frame.rst +++ b/doc/source/reference/frame.rst @@ -251,7 +251,7 @@ Combining / joining / merging DataFrame.merge DataFrame.update -Time series-related +Time Series-related ~~~~~~~~~~~~~~~~~~~ .. autosummary:: :toctree: api/ diff --git a/doc/source/reference/indexing.rst b/doc/source/reference/indexing.rst index ab6ea5aea6c61..ba12c19763605 100644 --- a/doc/source/reference/indexing.rst +++ b/doc/source/reference/indexing.rst @@ -328,7 +328,7 @@ DatetimeIndex DatetimeIndex -Time/Date components +Time/date components ~~~~~~~~~~~~~~~~~~~~ .. autosummary:: :toctree: api/ diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index 1a69fa076dbf0..ab0540a930396 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -110,7 +110,7 @@ Binary operator functions Series.product Series.dot -Function application, groupby & window +Function application, GroupBy & window -------------------------------------- .. autosummary:: :toctree: api/ @@ -249,7 +249,7 @@ Combining / joining / merging Series.replace Series.update -Time series-related +Time Series-related ------------------- .. autosummary:: :toctree: api/ diff --git a/doc/source/reference/window.rst b/doc/source/reference/window.rst index 3db1aa12a4275..570a0607ebd21 100644 --- a/doc/source/reference/window.rst +++ b/doc/source/reference/window.rst @@ -75,7 +75,7 @@ Exponentially-weighted moving window functions EWM.corr EWM.cov -Window Indexer +Window indexer -------------- .. currentmodule:: pandas diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 2aec4be6b301e..f1534181c9eb2 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -10,11 +10,11 @@ """ import argparse -import sys -import re -import os -from typing import Tuple, Generator, List import glob +import os +import re +import sys +from typing import Generator, List, Tuple CAPITALIZATION_EXCEPTIONS = { @@ -46,6 +46,61 @@ "NumFOCUS", "sklearn", "Docker", + "PeriodIndex", + "NA", + "NaN", + "ValueError", + "BooleanArray", + "KeyError", + "API", + "FAQ", + "IO", + "GroupBy", + "TimedeltaIndex", + "DatetimeIndex", + "IntervalIndex", + "CategoricalIndex", + "SPSS", + "ORC", + "R", + "HDF5", + "HDFStore", + "CDay", + "CBMonthBegin", + "CBMonthEnd", + "BMonthBegin", + "BMonthEnd", + "BDay", + "FY5253Quarter", + "FY5253", + "YearBegin", + "YearEnd", + "BYearBegin", + "BYearEnd", + "YearOffset", + "QuarterBegin", + "QuarterEnd", + "BQuarterBegin", + "BQuarterEnd", + "QuarterOffset", + "LastWeekOfMonth", + "WeekOfMonth", + "SemiMonthBegin", + "SemiMonthEnd", + "SemiMonthOffset", + "CustomBusinessMonthBegin", + "CustomBusinessMonthEnd", + "BusinessMonthBegin", + "BusinessMonthEnd", + "MonthBegin", + "MonthEnd", + "MonthOffset", + "CustomBusinessHour", + "CustomBusinessDay", + "BusinessHour", + "BusinessDay", + "DateOffset", + } CAP_EXCEPTIONS_DICT = {word.lower(): word for word in CAPITALIZATION_EXCEPTIONS} @@ -72,24 +127,7 @@ def correct_title_capitalization(title: str) -> str: # Strip all non-word characters from the beginning of the title to the # first word character. - correct_title: str = re.sub(r"^\W*", "", title) - - # Take into consideration words with multiple capital letters - # Such as DataFrame or PeriodIndex or IO to not lower them. - # Lower the other words - if re.search(r'((?:[A-Z]\w*){2,})', correct_title): - list_words: List[str] = correct_title.split(' ') - if correct_title[0].islower(): - list_words[0].replace(correct_title[0], correct_title[0].upper()) - - for idx in range(1, len(list_words)): - if not re.search(r'((?:[A-Z]\w*){2,})', list_words[idx]): - list_words[idx] = list_words[idx].lower() - - correct_title = " ".join(list_words) - - else: - correct_title = correct_title.capitalize() + correct_title: str = re.sub(r"^\W*", "", title).capitalize() # Remove a URL from the title. We do this because words in a URL must # stay lowercase, even if they are a capitalization exception. From f8b496c45921a515c6b7a2bae5d2a6cfe20228da Mon Sep 17 00:00:00 2001 From: clement Date: Mon, 23 Mar 2020 19:58:08 +0100 Subject: [PATCH 10/23] Remove wrong lines of code --- scripts/validate_rst_title_capitalization.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index a4734381a081f..f1534181c9eb2 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -15,10 +15,7 @@ import re import sys from typing import Generator, List, Tuple -<<<<<<< HEAD -======= ->>>>>>> temporary_repo/changes_to_pandas_remote CAPITALIZATION_EXCEPTIONS = { "pandas", @@ -104,10 +101,6 @@ "BusinessDay", "DateOffset", -<<<<<<< HEAD -======= - ->>>>>>> temporary_repo/changes_to_pandas_remote } CAP_EXCEPTIONS_DICT = {word.lower(): word for word in CAPITALIZATION_EXCEPTIONS} From 5d011896f3a6900476f37c4baca08b1045c67243 Mon Sep 17 00:00:00 2001 From: clement Date: Mon, 23 Mar 2020 19:59:17 +0100 Subject: [PATCH 11/23] Formatting --- scripts/validate_rst_title_capitalization.py | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index f1534181c9eb2..c69781b428c74 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -100,7 +100,6 @@ "BusinessHour", "BusinessDay", "DateOffset", - } CAP_EXCEPTIONS_DICT = {word.lower(): word for word in CAPITALIZATION_EXCEPTIONS} From 06dc1cdffcf596f577765f44088b16f15adbc0fc Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 25 Mar 2020 00:04:54 +0100 Subject: [PATCH 12/23] Remove exception "GroupBy" and lower "GroupBy" in doc --- doc/source/reference/series.rst | 2 +- scripts/validate_rst_title_capitalization.py | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index ab0540a930396..aa21ecdb54c7a 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -110,7 +110,7 @@ Binary operator functions Series.product Series.dot -Function application, GroupBy & window +Function application, groupby & window -------------------------------------- .. autosummary:: :toctree: api/ diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index c69781b428c74..98e7149cc0fff 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -55,7 +55,6 @@ "API", "FAQ", "IO", - "GroupBy", "TimedeltaIndex", "DatetimeIndex", "IntervalIndex", From a11dc2bcf5f3a10cfbd39671265edd51ad4e6bd8 Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 25 Mar 2020 09:25:24 +0100 Subject: [PATCH 13/23] modifying for PR --- pandas/tests/indexes/timedeltas/test_constructors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/indexes/timedeltas/test_constructors.py b/pandas/tests/indexes/timedeltas/test_constructors.py index 623b0d80a73dc..3e5bb56c3e58e 100644 --- a/pandas/tests/indexes/timedeltas/test_constructors.py +++ b/pandas/tests/indexes/timedeltas/test_constructors.py @@ -169,8 +169,8 @@ def test_constructor_coverage(self): timedelta_range(start="1 days", periods="foo", freq="D") msg = ( - r"TimedeltaIndex\(\) must be called with a collection of some kind," - " '1 days' was passed" + r"TimedeltaIndex\(\) must be called with a collection of some kind, " + "'1 days' was passed" ) with pytest.raises(TypeError, match=msg): TimedeltaIndex("1 days") From fc1009d6dc8fc715755cecfc670a14a58864688c Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 25 Mar 2020 19:33:18 +0100 Subject: [PATCH 14/23] Update "groupby" to "GroupBy" --- doc/source/reference/series.rst | 2 +- scripts/validate_rst_title_capitalization.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/source/reference/series.rst b/doc/source/reference/series.rst index aa21ecdb54c7a..ab0540a930396 100644 --- a/doc/source/reference/series.rst +++ b/doc/source/reference/series.rst @@ -110,7 +110,7 @@ Binary operator functions Series.product Series.dot -Function application, groupby & window +Function application, GroupBy & window -------------------------------------- .. autosummary:: :toctree: api/ diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 98e7149cc0fff..4e8df316d04b5 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -59,6 +59,7 @@ "DatetimeIndex", "IntervalIndex", "CategoricalIndex", + "GroupBy", "SPSS", "ORC", "R", From 0beeda1175290da952b167112ee1371250466040 Mon Sep 17 00:00:00 2001 From: clement Date: Sun, 29 Mar 2020 16:40:27 +0100 Subject: [PATCH 15/23] Commit changes to folder doc/source/development --- doc/source/development/code_style.rst | 4 ++-- doc/source/development/contributing_docstring.rst | 14 +++++++------- doc/source/development/developer.rst | 4 ++-- doc/source/development/extending.rst | 8 ++++---- doc/source/development/maintaining.rst | 12 ++++++------ doc/source/development/meeting.rst | 2 +- doc/source/development/policies.rst | 4 ++-- doc/source/development/roadmap.rst | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/doc/source/development/code_style.rst b/doc/source/development/code_style.rst index fa7532a68a06d..eca779e6800c8 100644 --- a/doc/source/development/code_style.rst +++ b/doc/source/development/code_style.rst @@ -18,7 +18,7 @@ consistent code format throughout the project. For details see the Patterns ======== -foo.__class__ +Foo.class ------------- @@ -47,7 +47,7 @@ String formatting Concatenated strings -------------------- -f-strings +F-strings ~~~~~~~~~ pandas uses f-strings formatting instead of '%' and '.format()' string formatters. diff --git a/doc/source/development/contributing_docstring.rst b/doc/source/development/contributing_docstring.rst index efa165e0a2d0c..24e14c7ca016c 100644 --- a/doc/source/development/contributing_docstring.rst +++ b/doc/source/development/contributing_docstring.rst @@ -160,7 +160,7 @@ backticks. The following are considered inline code: .. _docstring.short_summary: -Section 1: Short summary +Section 1: short summary ~~~~~~~~~~~~~~~~~~~~~~~~ The short summary is a single sentence that expresses what the function does in @@ -228,7 +228,7 @@ infinitive verb. .. _docstring.extended_summary: -Section 2: Extended summary +Section 2: extended summary ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The extended summary provides details on what the function does. It should not @@ -259,7 +259,7 @@ their use cases, if it is not too generic. .. _docstring.parameters: -Section 3: Parameters +Section 3: parameters ~~~~~~~~~~~~~~~~~~~~~ The details of the parameters will be added in this section. This section has @@ -424,7 +424,7 @@ For axis, the convention is to use something like: .. _docstring.returns: -Section 4: Returns or Yields +Section 4: returns or yields ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If the method returns a value, it will be documented in this section. Also @@ -505,7 +505,7 @@ If the method yields its value: .. _docstring.see_also: -Section 5: See Also +Section 5: see also ~~~~~~~~~~~~~~~~~~~ This section is used to let users know about pandas functionality @@ -583,7 +583,7 @@ For example: .. _docstring.notes: -Section 6: Notes +Section 6: notes ~~~~~~~~~~~~~~~~ This is an optional section used for notes about the implementation of the @@ -597,7 +597,7 @@ This section follows the same format as the extended summary section. .. _docstring.examples: -Section 7: Examples +Section 7: examples ~~~~~~~~~~~~~~~~~~~ This is one of the most important sections of a docstring, despite being diff --git a/doc/source/development/developer.rst b/doc/source/development/developer.rst index 33646e5d74757..3859f8b834da8 100644 --- a/doc/source/development/developer.rst +++ b/doc/source/development/developer.rst @@ -62,7 +62,7 @@ for each column, *including the index columns*. This has JSON form: See below for the detailed specification for these. -Index Metadata Descriptors +Index metadata descriptors ~~~~~~~~~~~~~~~~~~~~~~~~~~ ``RangeIndex`` can be stored as metadata only, not requiring serialization. The @@ -89,7 +89,7 @@ with other column names) a disambiguating name with pattern matching columns, ``name`` attribute is always stored in the column descriptors as above. -Column Metadata +Column metadata ~~~~~~~~~~~~~~~ ``pandas_type`` is the logical type of the column, and is one of: diff --git a/doc/source/development/extending.rst b/doc/source/development/extending.rst index 98e3ffcf74ad1..4b841becca254 100644 --- a/doc/source/development/extending.rst +++ b/doc/source/development/extending.rst @@ -95,7 +95,7 @@ on :ref:`ecosystem.extensions`. The interface consists of two classes. -:class:`~pandas.api.extensions.ExtensionDtype` +Class:~pandas.API.extensions.ExtensionDtype ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A :class:`pandas.api.extensions.ExtensionDtype` is similar to a ``numpy.dtype`` object. It describes the @@ -115,7 +115,7 @@ example ``'category'`` is a registered string accessor for the ``CategoricalDtyp See the `extension dtype dtypes`_ for more on how to register dtypes. -:class:`~pandas.api.extensions.ExtensionArray` +Class:~pandas.API.extensions.ExtensionArray ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This class provides all the array-like functionality. ExtensionArrays are @@ -139,7 +139,7 @@ and comments contain guidance for properly implementing the interface. .. _extending.extension.operator: -:class:`~pandas.api.extensions.ExtensionArray` Operator Support +Class:~pandas.API.extensions.ExtensionArray operator support ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. versionadded:: 0.24.0 @@ -210,7 +210,7 @@ will .. _extending.extension.ufunc: -NumPy Universal Functions +NumPy universal functions ^^^^^^^^^^^^^^^^^^^^^^^^^ :class:`Series` implements ``__array_ufunc__``. As part of the implementation, diff --git a/doc/source/development/maintaining.rst b/doc/source/development/maintaining.rst index 9ae9d47b89341..9f9e9dc2631f3 100644 --- a/doc/source/development/maintaining.rst +++ b/doc/source/development/maintaining.rst @@ -1,7 +1,7 @@ .. _maintaining: ****************** -Pandas Maintenance +pandas maintenance ****************** This guide is for pandas' maintainers. It may also be interesting to contributors @@ -41,7 +41,7 @@ reading. .. _maintaining.triage: -Issue Triage +Issue triage ------------ @@ -123,7 +123,7 @@ Here's a typical workflow for triaging a newly opened issue. .. _maintaining.closing: -Closing Issues +Closing issues -------------- Be delicate here: many people interpret closing an issue as us saying that the @@ -132,7 +132,7 @@ respond or self-close their issue if it's determined that the behavior is not a or the feature is out of scope. Sometimes reporters just go away though, and we'll close the issue after the conversation has died. -Reviewing Pull Requests +Reviewing pull requests ----------------------- Anybody can review a pull request: regular contributors, triagers, or core-team @@ -144,7 +144,7 @@ members. Here are some guidelines to check. * User-facing changes should have a whatsnew in the appropriate file. * Regression tests should reference the original GitHub issue number like ``# GH-1234``. -Cleaning up old Issues +Cleaning up old issues ---------------------- Every open issue in pandas has a cost. Open issues make finding duplicates harder, @@ -164,7 +164,7 @@ If an older issue lacks a reproducible example, label it as "Needs Info" and ask them to provide one (or write one yourself if possible). If one isn't provide reasonably soon, close it according to the policies in :ref:`maintaining.closing`. -Cleaning up old Pull Requests +Cleaning up old pull requests ----------------------------- Occasionally, contributors are unable to finish off a pull request. diff --git a/doc/source/development/meeting.rst b/doc/source/development/meeting.rst index 803f1b7002de0..b17c19f0f51f4 100644 --- a/doc/source/development/meeting.rst +++ b/doc/source/development/meeting.rst @@ -1,7 +1,7 @@ .. _meeting: ================== -Developer Meetings +Developer meetings ================== We hold regular developer meetings on the second Wednesday diff --git a/doc/source/development/policies.rst b/doc/source/development/policies.rst index b7cc3db3ad260..1031bbfc46457 100644 --- a/doc/source/development/policies.rst +++ b/doc/source/development/policies.rst @@ -6,7 +6,7 @@ Policies .. _policies.version: -Version Policy +Version policy ~~~~~~~~~~~~~~ .. versionchanged:: 1.0.0 @@ -48,7 +48,7 @@ deprecation removed in the next next major release (2.0.0). These policies do not apply to features marked as **experimental** in the documentation. pandas may change the behavior of experimental features at any time. -Python Support +Python support ~~~~~~~~~~~~~~ pandas will only drop support for specific Python versions (e.g. 3.6.x, 3.7.x) in diff --git a/doc/source/development/roadmap.rst b/doc/source/development/roadmap.rst index e57ff82add278..d331491d02883 100644 --- a/doc/source/development/roadmap.rst +++ b/doc/source/development/roadmap.rst @@ -152,7 +152,7 @@ We'd like to fund improvements and maintenance of these tools to .. _roadmap.evolution: -Roadmap Evolution +Roadmap evolution ----------------- pandas continues to evolve. The direction is primarily determined by community From f48b2dd2fa666ecb13f62a248dd3ed7ea0bb7ec3 Mon Sep 17 00:00:00 2001 From: clement Date: Sun, 29 Mar 2020 16:44:15 +0100 Subject: [PATCH 16/23] Add keywords to CAPITALIZATION_EXCEPTIONS --- scripts/validate_rst_title_capitalization.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 4e8df316d04b5..a3fea625e12d1 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -100,6 +100,8 @@ "BusinessHour", "BusinessDay", "DateOffset", + "ExtensionDtype", + "ExtensionArray", } CAP_EXCEPTIONS_DICT = {word.lower(): word for word in CAPITALIZATION_EXCEPTIONS} From 7c0961079161f1da2e75972f6ec261f552cc715e Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 1 Apr 2020 15:08:12 +0100 Subject: [PATCH 17/23] Commit and updating documentation syntax and capitalization for folder doc/source/development Updating script validate_rst_title_capitalization.py to avoid taking into account titles beginning with ':' --- doc/source/development/code_style.rst | 8 ++++---- doc/source/development/extending.rst | 6 +++--- scripts/validate_rst_title_capitalization.py | 3 +++ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/source/development/code_style.rst b/doc/source/development/code_style.rst index eca779e6800c8..6d33537a40175 100644 --- a/doc/source/development/code_style.rst +++ b/doc/source/development/code_style.rst @@ -18,8 +18,8 @@ consistent code format throughout the project. For details see the Patterns ======== -Foo.class -------------- +Using foo.__class__ +------------------- pandas uses 'type(foo)' instead 'foo.__class__' as it is making the code more @@ -47,8 +47,8 @@ String formatting Concatenated strings -------------------- -F-strings -~~~~~~~~~ +Using f-strings +~~~~~~~~~~~~~~~ pandas uses f-strings formatting instead of '%' and '.format()' string formatters. diff --git a/doc/source/development/extending.rst b/doc/source/development/extending.rst index 72b63a2b3025c..d9fb2643e8a1a 100644 --- a/doc/source/development/extending.rst +++ b/doc/source/development/extending.rst @@ -95,7 +95,7 @@ on :ref:`ecosystem.extensions`. The interface consists of two classes. -Class:~pandas.API.extensions.ExtensionDtype +:class:`~pandas.api.extensions.ExtensionDtype` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ A :class:`pandas.api.extensions.ExtensionDtype` is similar to a ``numpy.dtype`` object. It describes the @@ -115,7 +115,7 @@ example ``'category'`` is a registered string accessor for the ``CategoricalDtyp See the `extension dtype dtypes`_ for more on how to register dtypes. -Class:~pandas.API.extensions.ExtensionArray +:class:`~pandas.api.extensions.ExtensionArray` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This class provides all the array-like functionality. ExtensionArrays are @@ -139,7 +139,7 @@ and comments contain guidance for properly implementing the interface. .. _extending.extension.operator: -Class:~pandas.API.extensions.ExtensionArray operator support +:class:`~pandas.api.extensions.ExtensionArray` operator support ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. versionadded:: 0.24.0 diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index a3fea625e12d1..52939252f5123 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -177,6 +177,7 @@ def find_titles(rst_file: str) -> Generator[Tuple[str, int], None, None]: len(line_chars) == 1 and line_chars.pop() in symbols and len(line) == len(previous_line) + and previous_line[0] != ':' ): yield re.sub(r"[`\*_]", "", previous_line), i previous_line = line @@ -233,6 +234,8 @@ def main(source_paths: List[str], output_format: str) -> bool: for filename in find_rst_files(source_paths): for title, line_number in find_titles(filename): + if ":class" in title: + print(title) if title != correct_title_capitalization(title): print( f"""{filename}:{line_number}:{err_msg} "{title}" to "{ From 940109db7e71a79dd9ee53a6a8202479a2dbc90a Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 1 Apr 2020 15:14:08 +0100 Subject: [PATCH 18/23] Remove the 'ExtensionDtype' and 'ExtensionArray' exceptions from 'CAPITALIZATION_EXCEPTIONS' that are present in title with special encoding, as it is not necessary anymore --- scripts/validate_rst_title_capitalization.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 52939252f5123..446c403d94ec6 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -100,8 +100,6 @@ "BusinessHour", "BusinessDay", "DateOffset", - "ExtensionDtype", - "ExtensionArray", } CAP_EXCEPTIONS_DICT = {word.lower(): word for word in CAPITALIZATION_EXCEPTIONS} From 35b1a37287ed6f152c191d239ee3e0baa42487d1 Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 1 Apr 2020 15:19:52 +0100 Subject: [PATCH 19/23] Style formatting --- scripts/validate_rst_title_capitalization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 446c403d94ec6..141d6e04e07f9 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -175,7 +175,7 @@ def find_titles(rst_file: str) -> Generator[Tuple[str, int], None, None]: len(line_chars) == 1 and line_chars.pop() in symbols and len(line) == len(previous_line) - and previous_line[0] != ':' + and previous_line[0] != ":" ): yield re.sub(r"[`\*_]", "", previous_line), i previous_line = line From 5f0512e35dfc7e918bf28721ffdd4e9fb8217312 Mon Sep 17 00:00:00 2001 From: clement Date: Wed, 1 Apr 2020 15:26:43 +0100 Subject: [PATCH 20/23] Correct error by removing wrong lines of code in validate_rst_title_capitalization.py --- scripts/validate_rst_title_capitalization.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 141d6e04e07f9..030cf8d8e8474 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -232,8 +232,6 @@ def main(source_paths: List[str], output_format: str) -> bool: for filename in find_rst_files(source_paths): for title, line_number in find_titles(filename): - if ":class" in title: - print(title) if title != correct_title_capitalization(title): print( f"""{filename}:{line_number}:{err_msg} "{title}" to "{ From 7767d3ce4ce4ce5152c0a6ee6cbe54bdca8ae910 Mon Sep 17 00:00:00 2001 From: clement Date: Thu, 2 Apr 2020 13:26:41 +0100 Subject: [PATCH 21/23] Weird behaviour file 'pandas/tests/frame/indexing/test_setitem.py' not tracked anymore? Add it to repository --- pandas/tests/frame/indexing/test_setitem.py | 86 +++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 pandas/tests/frame/indexing/test_setitem.py diff --git a/pandas/tests/frame/indexing/test_setitem.py b/pandas/tests/frame/indexing/test_setitem.py new file mode 100644 index 0000000000000..c12643f413490 --- /dev/null +++ b/pandas/tests/frame/indexing/test_setitem.py @@ -0,0 +1,86 @@ +import numpy as np +import pytest + +from pandas import DataFrame, Index, Series +import pandas._testing as tm + +# Column add, remove, delete. + + +class TestDataFrameMutateColumns: + def test_setitem_error_msmgs(self): + + # GH 7432 + df = DataFrame( + {"bar": [1, 2, 3], "baz": ["d", "e", "f"]}, + index=Index(["a", "b", "c"], name="foo"), + ) + ser = Series( + ["g", "h", "i", "j"], + index=Index(["a", "b", "c", "a"], name="foo"), + name="fiz", + ) + msg = "cannot reindex from a duplicate axis" + with pytest.raises(ValueError, match=msg): + df["newcol"] = ser + + # GH 4107, more descriptive error message + df = DataFrame(np.random.randint(0, 2, (4, 4)), columns=["a", "b", "c", "d"]) + + msg = "incompatible index of inserted column with frame index" + with pytest.raises(TypeError, match=msg): + df["gr"] = df.groupby(["b", "c"]).count() + + def test_setitem_benchmark(self): + # from the vb_suite/frame_methods/frame_insert_columns + N = 10 + K = 5 + df = DataFrame(index=range(N)) + new_col = np.random.randn(N) + for i in range(K): + df[i] = new_col + expected = DataFrame(np.repeat(new_col, K).reshape(N, K), index=range(N)) + tm.assert_frame_equal(df, expected) + + def test_setitem_different_dtype(self): + df = DataFrame( + np.random.randn(5, 3), index=np.arange(5), columns=["c", "b", "a"] + ) + df.insert(0, "foo", df["a"]) + df.insert(2, "bar", df["c"]) + + # diff dtype + + # new item + df["x"] = df["a"].astype("float32") + result = df.dtypes + expected = Series( + [np.dtype("float64")] * 5 + [np.dtype("float32")], + index=["foo", "c", "bar", "b", "a", "x"], + ) + tm.assert_series_equal(result, expected) + + # replacing current (in different block) + df["a"] = df["a"].astype("float32") + result = df.dtypes + expected = Series( + [np.dtype("float64")] * 4 + [np.dtype("float32")] * 2, + index=["foo", "c", "bar", "b", "a", "x"], + ) + tm.assert_series_equal(result, expected) + + df["y"] = df["a"].astype("int32") + result = df.dtypes + expected = Series( + [np.dtype("float64")] * 4 + [np.dtype("float32")] * 2 + [np.dtype("int32")], + index=["foo", "c", "bar", "b", "a", "x", "y"], + ) + tm.assert_series_equal(result, expected) + + def test_setitem_empty_columns(self): + # GH 13522 + df = DataFrame(index=["A", "B", "C"]) + df["X"] = df.index + df["X"] = ["x", "y", "z"] + exp = DataFrame(data={"X": ["x", "y", "z"]}, index=["A", "B", "C"]) + tm.assert_frame_equal(df, exp) From 5fc4dcc70cfc9a8e3f34c732babc4f1ee844dca9 Mon Sep 17 00:00:00 2001 From: clement Date: Thu, 2 Apr 2020 16:20:31 +0100 Subject: [PATCH 22/23] Commit modifying script 'validate_rst_title_capitalization.py' to change the way code excludes specific title syntax from being seen as an error --- scripts/validate_rst_title_capitalization.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index cf9b2ad0b3b09..65ab1ee9653b0 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -11,21 +11,11 @@ """ import argparse import glob -<<<<<<< HEAD import os import re import sys from typing import Generator, List, Tuple -||||||| 49bc8d8c9 - -======= -import os -import re -import sys -from typing import Generator, List, Tuple ->>>>>>> upstream_main_pandas/master - CAPITALIZATION_EXCEPTIONS = { "pandas", "Python", @@ -133,6 +123,10 @@ def correct_title_capitalization(title: str) -> str: Correctly capitalized heading. """ + # Skip modification no matter what if title begins by ":" to exclude specific syntax that is needed to build links. + if title[0] == ":": + return title + # Strip all non-word characters from the beginning of the title to the # first word character. correct_title: str = re.sub(r"^\W*", "", title).capitalize() @@ -184,7 +178,6 @@ def find_titles(rst_file: str) -> Generator[Tuple[str, int], None, None]: len(line_chars) == 1 and line_chars.pop() in symbols and len(line) == len(previous_line) - and previous_line[0] != ":" ): yield re.sub(r"[`\*_]", "", previous_line), i previous_line = line From 0ad8143bfc99c1dce2ed0a4b68e475dfc938b812 Mon Sep 17 00:00:00 2001 From: clement Date: Thu, 2 Apr 2020 16:52:46 +0100 Subject: [PATCH 23/23] Correct style errors --- scripts/validate_rst_title_capitalization.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/validate_rst_title_capitalization.py b/scripts/validate_rst_title_capitalization.py index 65ab1ee9653b0..59d422a1605a0 100755 --- a/scripts/validate_rst_title_capitalization.py +++ b/scripts/validate_rst_title_capitalization.py @@ -123,7 +123,8 @@ def correct_title_capitalization(title: str) -> str: Correctly capitalized heading. """ - # Skip modification no matter what if title begins by ":" to exclude specific syntax that is needed to build links. + # Skip modification no matter what if title begins by ":" to exclude specific + # syntax that is needed to build links. if title[0] == ":": return title