diff --git a/doc/source/user_guide/io.rst b/doc/source/user_guide/io.rst index 88f6cf76941ef..eb4f9c9f5801f 100644 --- a/doc/source/user_guide/io.rst +++ b/doc/source/user_guide/io.rst @@ -343,7 +343,7 @@ on_bad_lines : {{'error', 'warn', 'skip'}}, default 'error' Specifies what to do upon encountering a bad line (a line with too many fields). Allowed values are : - - 'error', raise an ParserError when a bad line is encountered. + - 'error', raise a ParserError when a bad line is encountered. - 'warn', print a warning when a bad line is encountered and skip that line. - 'skip', skip bad lines without raising or warning when they are encountered. diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 7f1b772f38185..c2c1cec336e5f 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -2593,7 +2593,7 @@ def maybe_convert_objects(ndarray[object] objects, Whether to convert numeric entries. convert_to_nullable_dtype : bool, default False If an array-like object contains only integer or boolean values (and NaN) is - encountered, whether to convert and return an Boolean/IntegerArray. + encountered, whether to convert and return a Boolean/IntegerArray. convert_non_numeric : bool, default False Whether to convert datetime, timedelta, period, interval types. dtype_if_all_nat : np.dtype, ExtensionDtype, or None, default None diff --git a/pandas/_libs/tslibs/fields.pyx b/pandas/_libs/tslibs/fields.pyx index c1db313fa5157..262ced3fd7abc 100644 --- a/pandas/_libs/tslibs/fields.pyx +++ b/pandas/_libs/tslibs/fields.pyx @@ -146,7 +146,7 @@ def get_date_name_field( NPY_DATETIMEUNIT reso=NPY_FR_ns, ): """ - Given a int64-based datetime index, return array of strings of date + Given an int64-based datetime index, return array of strings of date name based on requested field (e.g. day_name) """ cdef: @@ -335,7 +335,7 @@ def get_date_field( NPY_DATETIMEUNIT reso=NPY_FR_ns, ): """ - Given a int64-based datetime index, extract the year, month, etc., + Given an int64-based datetime index, extract the year, month, etc., field and return an array of these values. """ cdef: @@ -502,7 +502,7 @@ def get_timedelta_field( NPY_DATETIMEUNIT reso=NPY_FR_ns, ): """ - Given a int64-based timedelta index, extract the days, hrs, sec., + Given an int64-based timedelta index, extract the days, hrs, sec., field and return an array of these values. """ cdef: @@ -555,7 +555,7 @@ def get_timedelta_days( NPY_DATETIMEUNIT reso=NPY_FR_ns, ): """ - Given a int64-based timedelta index, extract the days, + Given an int64-based timedelta index, extract the days, field and return an array of these values. """ cdef: @@ -592,7 +592,7 @@ cpdef isleapyear_arr(ndarray years): @cython.boundscheck(False) def build_isocalendar_sarray(const int64_t[:] dtindex, NPY_DATETIMEUNIT reso): """ - Given a int64-based datetime array, return the ISO 8601 year, week, and day + Given an int64-based datetime array, return the ISO 8601 year, week, and day as a structured array. """ cdef: diff --git a/pandas/_libs/tslibs/offsets.pyx b/pandas/_libs/tslibs/offsets.pyx index 6f9a1ba34bde9..4790d2f6b0c48 100644 --- a/pandas/_libs/tslibs/offsets.pyx +++ b/pandas/_libs/tslibs/offsets.pyx @@ -827,7 +827,7 @@ cdef class BaseOffset: @property def nanos(self): """ - Returns a integer of the total number of nanoseconds for fixed frequencies. + Returns an integer of the total number of nanoseconds for fixed frequencies. Raises ------ diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 2d18a275f26f5..8343d51dcb4f1 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -334,7 +334,7 @@ cdef convert_to_timedelta64(object ts, str unit): Handle these types of objects: - timedelta/Timedelta - Return an timedelta64[ns] object + Return a timedelta64[ns] object """ # Caller is responsible for checking unit not in ["Y", "y", "M"] if isinstance(ts, _Timedelta): diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index afbefd9b84461..b2a2918f95b4c 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -1717,7 +1717,7 @@ cdef class _Timestamp(ABCTimestamp): def to_period(self, freq=None): """ - Return an period of which this timestamp is an observation. + Return a period of which this timestamp is an observation. This method converts the given Timestamp to a Period object, which represents a span of time,such as a year, month, etc., diff --git a/pandas/core/arrays/boolean.py b/pandas/core/arrays/boolean.py index 2d7bae7833f29..35c37394873a5 100644 --- a/pandas/core/arrays/boolean.py +++ b/pandas/core/arrays/boolean.py @@ -273,7 +273,7 @@ class BooleanArray(BaseMaskedArray): BooleanArray implements Kleene logic (sometimes called three-value logic) for logical operations. See :ref:`boolean.kleene` for more. - To construct an BooleanArray from generic array-like input, use + To construct a BooleanArray from generic array-like input, use :func:`pandas.array` specifying ``dtype="boolean"`` (see examples below). @@ -313,7 +313,7 @@ class BooleanArray(BaseMaskedArray): Examples -------- - Create an BooleanArray with :func:`pandas.array`: + Create a BooleanArray with :func:`pandas.array`: >>> pd.array([True, False, None], dtype="boolean") diff --git a/pandas/core/arrays/datetimes.py b/pandas/core/arrays/datetimes.py index 9b7ae26bef899..4fcd632fb849f 100644 --- a/pandas/core/arrays/datetimes.py +++ b/pandas/core/arrays/datetimes.py @@ -1205,7 +1205,7 @@ def to_period(self, freq=None) -> PeriodArray: ---------- freq : str or Period, optional One of pandas' :ref:`period aliases ` - or an Period object. Will be inferred by default. + or a Period object. Will be inferred by default. Returns ------- diff --git a/pandas/core/arrays/floating.py b/pandas/core/arrays/floating.py index e547c3fe76089..58ce1eab86fc5 100644 --- a/pandas/core/arrays/floating.py +++ b/pandas/core/arrays/floating.py @@ -78,7 +78,7 @@ class FloatingArray(NumericArray): - data: contains a numpy float array of the appropriate dtype - mask: a boolean array holding a mask on the data, True is missing - To construct an FloatingArray from generic array-like input, use + To construct a FloatingArray from generic array-like input, use :func:`pandas.array` with one of the float dtypes (see examples). See :ref:`integer_na` for more. @@ -114,7 +114,7 @@ class FloatingArray(NumericArray): Examples -------- - Create an FloatingArray with :func:`pandas.array`: + Create a FloatingArray with :func:`pandas.array`: >>> pd.array([0.1, None, 0.3], dtype=pd.Float32Dtype()) diff --git a/pandas/core/base.py b/pandas/core/base.py index 7d7e43808be5c..6536812991731 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -1120,7 +1120,7 @@ def nunique(self, dropna: bool = True) -> int: Returns ------- int - A integer indicating the number of unique elements in the object. + An integer indicating the number of unique elements in the object. See Also -------- diff --git a/pandas/core/dtypes/astype.py b/pandas/core/dtypes/astype.py index 94b92ead92374..b21c6e3fb33fb 100644 --- a/pandas/core/dtypes/astype.py +++ b/pandas/core/dtypes/astype.py @@ -140,7 +140,7 @@ def _astype_float_to_int_nansafe( values: np.ndarray, dtype: np.dtype, copy: bool ) -> np.ndarray: """ - astype with a check preventing converting NaN to an meaningless integer value. + astype with a check preventing converting NaN to a meaningless integer value. """ if not np.isfinite(values).all(): raise IntCastingNaNError( diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 2e3d73edcdf4f..56e5758e21b4b 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -1387,7 +1387,7 @@ def construct_from_string(cls, string: str_type) -> IntervalDtype: return cls(string) msg = ( - f"Cannot construct a 'IntervalDtype' from '{string}'.\n\n" + f"Cannot construct an 'IntervalDtype' from '{string}'.\n\n" "Incorrectly formatted string passed to constructor. " "Valid formats include Interval or Interval[dtype] " "where dtype is numeric, datetime, or timedelta" diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 67e03ec791e2c..0f9938916b8df 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2868,7 +2868,7 @@ def drop_duplicates(self, *, keep: DropKeep = "first") -> Self: Examples -------- - Generate an pandas.Index with duplicate values. + Generate a pandas.Index with duplicate values. >>> idx = pd.Index(["llama", "cow", "llama", "beetle", "llama", "hippo"]) diff --git a/pandas/core/indexes/extension.py b/pandas/core/indexes/extension.py index 2eeacfb769be4..3b4fa372eec04 100644 --- a/pandas/core/indexes/extension.py +++ b/pandas/core/indexes/extension.py @@ -115,7 +115,7 @@ def inherit_names( names: list[str], delegate: type, cache: bool = False, wrap: bool = False ) -> Callable[[type[_ExtensionIndexT]], type[_ExtensionIndexT]]: """ - Class decorator to pin attributes from an ExtensionArray to a Index subclass. + Class decorator to pin attributes from an ExtensionArray to an Index subclass. Parameters ---------- diff --git a/pandas/core/util/hashing.py b/pandas/core/util/hashing.py index 3c4ad1d50f85e..3d2e65f79e43a 100644 --- a/pandas/core/util/hashing.py +++ b/pandas/core/util/hashing.py @@ -188,7 +188,7 @@ def hash_tuples( hash_key: str = _default_hash_key, ) -> npt.NDArray[np.uint64]: """ - Hash an MultiIndex / listlike-of-tuples efficiently. + Hash a MultiIndex / listlike-of-tuples efficiently. Parameters ---------- @@ -261,7 +261,7 @@ def hash_array( See Also -------- util.hash_pandas_object : Return a data hash of the Index/Series/DataFrame. - util.hash_tuples : Hash an MultiIndex / listlike-of-tuples efficiently. + util.hash_tuples : Hash a MultiIndex / listlike-of-tuples efficiently. Examples -------- diff --git a/pandas/io/excel/_xlsxwriter.py b/pandas/io/excel/_xlsxwriter.py index 4a7b8eee2bfce..a6c0346065e7e 100644 --- a/pandas/io/excel/_xlsxwriter.py +++ b/pandas/io/excel/_xlsxwriter.py @@ -102,7 +102,7 @@ def convert(cls, style_dict, num_format_str=None) -> dict[str, Any]: style_dict : style dictionary to convert num_format_str : optional number format string """ - # Create a XlsxWriter format object. + # Create an XlsxWriter format object. props = {} if num_format_str is not None: diff --git a/pandas/io/parsers/python_parser.py b/pandas/io/parsers/python_parser.py index b08e013d7acb8..55a219eba1c61 100644 --- a/pandas/io/parsers/python_parser.py +++ b/pandas/io/parsers/python_parser.py @@ -669,8 +669,8 @@ def _infer_columns( this_columns[i] = col counts[col] = cur_count + 1 elif have_mi_columns: - # if we have grabbed an extra line, but its not in our - # format so save in the buffer, and create an blank extra + # if we have grabbed an extra line, but it's not in our + # format so save in the buffer, and create a blank extra # line for the rest of the parsing code if hr == header[-1]: lc = len(this_columns) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index f7980ea01843e..ab10935a60918 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -4999,7 +4999,7 @@ def indexables(self): # error: Signature of "write" incompatible with supertype "AppendableTable" def write(self, **kwargs) -> None: # type: ignore[override] - raise NotImplementedError("cannot write on an generic table") + raise NotImplementedError("cannot write on a generic table") class AppendableMultiFrameTable(AppendableFrameTable): @@ -5371,7 +5371,7 @@ def _need_convert(kind: str) -> bool: def _maybe_adjust_name(name: str, version: Sequence[int]) -> str: """ - Prior to 0.10.1, we named values blocks like: values_block_0 an the + Prior to 0.10.1, we named values blocks like: values_block_0 and the name values_0, adjust the given name if necessary. Parameters diff --git a/pandas/tests/generic/test_label_or_level_utils.py b/pandas/tests/generic/test_label_or_level_utils.py index 80c24c647bc11..797f3d488ab18 100644 --- a/pandas/tests/generic/test_label_or_level_utils.py +++ b/pandas/tests/generic/test_label_or_level_utils.py @@ -84,10 +84,10 @@ def test_is_level_reference_df_ambig(df_ambig, axis): assert_label_reference(df_ambig, ["L1"], axis=axis) # df has an on-axis level named L2 and it is not ambiguous - # Therefore L2 is an level reference + # Therefore L2 is a level reference assert_level_reference(df_ambig, ["L2"], axis=axis) - # df has a column named L3 and it not an level reference + # df has a column named L3 and it is not a level reference assert_label_reference(df_ambig, ["L3"], axis=axis) diff --git a/pandas/tests/indexes/period/test_constructors.py b/pandas/tests/indexes/period/test_constructors.py index ecaaf6183c027..310f6e5628a40 100644 --- a/pandas/tests/indexes/period/test_constructors.py +++ b/pandas/tests/indexes/period/test_constructors.py @@ -139,7 +139,7 @@ def test_base_constructor_with_period_dtype(self): "values_constructor", [list, np.array, PeriodIndex, PeriodArray._from_sequence] ) def test_index_object_dtype(self, values_constructor): - # Index(periods, dtype=object) is an Index (not an PeriodIndex) + # Index(periods, dtype=object) is an Index (not a PeriodIndex) periods = [ Period("2011-01", freq="M"), NaT, diff --git a/pandas/tests/io/excel/test_odf.py b/pandas/tests/io/excel/test_odf.py index f01827fa4ca2f..7ce720c9e1345 100644 --- a/pandas/tests/io/excel/test_odf.py +++ b/pandas/tests/io/excel/test_odf.py @@ -24,7 +24,7 @@ def test_read_invalid_types_raises(): def test_read_writer_table(): - # Also test reading tables from an text OpenDocument file + # Also test reading tables from a text OpenDocument file # (.odt) index = pd.Index(["Row 1", "Row 2", "Row 3"], name="Header") expected = pd.DataFrame( diff --git a/pandas/tests/strings/test_extract.py b/pandas/tests/strings/test_extract.py index 1dc7dbabe85b0..cc98690c882f5 100644 --- a/pandas/tests/strings/test_extract.py +++ b/pandas/tests/strings/test_extract.py @@ -682,7 +682,7 @@ def test_extractall_same_as_extract(any_string_dtype): def test_extractall_same_as_extract_subject_index(any_string_dtype): - # same as above tests, but s has an MultiIndex. + # same as above tests, but s has a MultiIndex. mi = MultiIndex.from_tuples( [("A", "first"), ("B", "second"), ("C", "third")], names=("capital", "ordinal"),