Skip to content

Commit

Permalink
DOC: resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
tuhinsharma121 committed Apr 29, 2024
2 parents 340eb71 + cf0014a commit ae83009
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 22 deletions.
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.DataFrame.var PR01,RT03,SA01" \
-i "pandas.DatetimeIndex.indexer_at_time PR01,RT03" \
-i "pandas.DatetimeIndex.snap PR01,RT03" \
-i "pandas.DatetimeIndex.to_pydatetime RT03,SA01" \
-i "pandas.Grouper PR02" \
-i "pandas.Index PR07" \
-i "pandas.Index.append PR07,RT03,SA01" \
-i "pandas.Index.difference PR07,RT03,SA01" \
-i "pandas.Index.drop PR07,SA01" \
-i "pandas.Index.duplicated RT03" \
-i "pandas.Index.get_indexer PR07,SA01" \
-i "pandas.Index.get_indexer_for PR01,SA01" \
Expand All @@ -119,7 +117,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Index.nunique RT03" \
-i "pandas.Index.putmask PR01,RT03" \
-i "pandas.Index.ravel PR01,RT03" \
-i "pandas.Index.reindex PR07" \
-i "pandas.Index.slice_indexer PR07,RT03,SA01" \
-i "pandas.Index.str PR01,SA01" \
-i "pandas.Index.symmetric_difference PR07,RT03,SA01" \
Expand Down
6 changes: 6 additions & 0 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,12 @@ def to_pydatetime(self) -> npt.NDArray[np.object_]:
Returns
-------
numpy.ndarray
An ndarray of ``datetime.datetime`` objects.
See Also
--------
DatetimeIndex.to_julian_date : Converts Datetime Array to float64 ndarray
of Julian Dates.
Examples
--------
Expand Down
8 changes: 8 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3953,6 +3953,7 @@ def reindex(
Parameters
----------
target : an iterable
An iterable containing the values to be used for creating the new index.
method : {None, 'pad'/'ffill', 'backfill'/'bfill', 'nearest'}, optional
* default: exact matches only.
* pad / ffill: find the PREVIOUS index value if no exact match.
Expand Down Expand Up @@ -6686,6 +6687,8 @@ def drop(
Parameters
----------
labels : array-like or scalar
Array-like object or a scalar value, representing the labels to be removed
from the Index.
errors : {'ignore', 'raise'}, default 'raise'
If 'ignore', suppress error and existing labels are dropped.
Expand All @@ -6699,6 +6702,11 @@ def drop(
KeyError
If not all of the labels are found in the selected axis
See Also
--------
Index.dropna : Return Index without NA/NaN values.
Index.drop_duplicates : Return Index with duplicate values removed.
Examples
--------
>>> idx = pd.Index(["a", "b", "c"])
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/excel/_xlsxwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class _XlsxStyler:
}

@classmethod
def convert(cls, style_dict, num_format_str=None):
def convert(cls, style_dict, num_format_str=None) -> dict[str, Any]:
"""
converts a style_dict to an xlsxwriter format dict
Expand Down
39 changes: 23 additions & 16 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
Final,
Literal,
cast,
overload,
)
import warnings

Expand Down Expand Up @@ -593,7 +594,7 @@ def __getitem__(self, key: str):
def __setitem__(self, key: str, value) -> None:
self.put(key, value)

def __delitem__(self, key: str) -> None:
def __delitem__(self, key: str) -> int | None:
return self.remove(key)

def __getattr__(self, name: str):
Expand Down Expand Up @@ -1203,7 +1204,7 @@ def put(
dropna=dropna,
)

def remove(self, key: str, where=None, start=None, stop=None) -> None:
def remove(self, key: str, where=None, start=None, stop=None) -> int | None:
"""
Remove pandas object partially by specifying the where condition
Expand Down Expand Up @@ -1251,14 +1252,12 @@ def remove(self, key: str, where=None, start=None, stop=None) -> None:
# remove the node
if com.all_none(where, start, stop):
s.group._f_remove(recursive=True)
return None

# delete from the table
else:
if not s.is_table:
raise ValueError(
"can only remove with where on objects written as tables"
)
return s.delete(where=where, start=start, stop=stop)
if not s.is_table:
raise ValueError("can only remove with where on objects written as tables")
return s.delete(where=where, start=start, stop=stop)

def append(
self,
Expand Down Expand Up @@ -2895,7 +2894,7 @@ def read(
columns=None,
start: int | None = None,
stop: int | None = None,
):
) -> Series | DataFrame:
raise NotImplementedError(
"cannot read on an abstract storer: subclasses should implement"
)
Expand All @@ -2907,7 +2906,7 @@ def write(self, obj, **kwargs) -> None:

def delete(
self, where=None, start: int | None = None, stop: int | None = None
) -> None:
) -> int | None:
"""
support fully deleting the node in its entirety (only) - where
specification must be None
Expand Down Expand Up @@ -3601,7 +3600,7 @@ def queryables(self) -> dict[str, Any]:

return dict(d1 + d2 + d3)

def index_cols(self):
def index_cols(self) -> list[tuple[Any, Any]]:
"""return a list of my index cols"""
# Note: each `i.cname` below is assured to be a str.
return [(i.axis, i.cname) for i in self.index_axes]
Expand Down Expand Up @@ -3731,7 +3730,7 @@ def indexables(self):
dc = set(self.data_columns)
base_pos = len(_indexables)

def f(i, c):
def f(i, c: str) -> DataCol:
assert isinstance(c, str)
klass = DataCol
if c in dc:
Expand Down Expand Up @@ -3897,7 +3896,7 @@ def get_object(cls, obj, transposed: bool):
"""return the data for this obj"""
return obj

def validate_data_columns(self, data_columns, min_itemsize, non_index_axes):
def validate_data_columns(self, data_columns, min_itemsize, non_index_axes) -> list:
"""
take the input data_columns and min_itemize and create a data
columns spec
Expand Down Expand Up @@ -4590,7 +4589,9 @@ def write_data_chunk(
self.table.append(rows)
self.table.flush()

def delete(self, where=None, start: int | None = None, stop: int | None = None):
def delete(
self, where=None, start: int | None = None, stop: int | None = None
) -> int | None:
# delete all rows (and return the nrows)
if where is None or not len(where):
if start is None and stop is None:
Expand Down Expand Up @@ -4918,7 +4919,7 @@ def read(
columns=None,
start: int | None = None,
stop: int | None = None,
):
) -> DataFrame:
df = super().read(where=where, columns=columns, start=start, stop=stop)
df = df.set_index(self.levels)

Expand Down Expand Up @@ -5379,7 +5380,13 @@ def __init__(
if self.terms is not None:
self.condition, self.filter = self.terms.evaluate()

def generate(self, where):
@overload
def generate(self, where: dict | list | tuple | str) -> PyTablesExpr: ...

@overload
def generate(self, where: None) -> None: ...

def generate(self, where: dict | list | tuple | str | None) -> PyTablesExpr | None:
"""where can be a : dict,list,tuple,string"""
if where is None:
return None
Expand Down
4 changes: 2 additions & 2 deletions pandas/util/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def indent(text: str | None, indents: int = 1) -> str:
]


def set_module(module):
def set_module(module) -> Callable[[F], F]:
"""Private decorator for overriding __module__ on a function or class.
Example usage::
Expand All @@ -518,7 +518,7 @@ def example():
assert example.__module__ == "pandas"
"""

def decorator(func):
def decorator(func: F) -> F:
if module is not None:
func.__module__ = module
return func
Expand Down

0 comments on commit ae83009

Please sign in to comment.