Skip to content

Commit a9aa29e

Browse files
DOC: Fix ES01 for pandas.DataFrame (#64034)
1 parent fc4c5e5 commit a9aa29e

File tree

4 files changed

+44
-20
lines changed

4 files changed

+44
-20
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,12 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
123123
-i "pandas.Series.is_unique ES01" \
124124
-i "pandas.Series.is_monotonic_increasing ES01" \
125125
-i "pandas.Series.is_monotonic_decreasing ES01" \
126-
-i "pandas.Series.droplevel ES01" \
127126
-i "pandas.Series.drop_duplicates ES01" \
128127
-i "pandas.Series.rename_axis ES01" \
129128
-i "pandas.Series.mask ES01" \
130-
-i "pandas.Series.ffill ES01" \
131-
-i "pandas.Series.fillna ES01" \
132129
-i "pandas.Series.unstack ES01" \
133130
-i "pandas.Series.explode ES01" \
134131
-i "pandas.Series.compare ES01" \
135-
-i "pandas.Series.tz_convert ES01" \
136132
-i "pandas.Series.at_time ES01" \
137133
-i "pandas.Series.cat ES01" \
138134
-i "pandas.Series.sparse ES01" \
@@ -149,7 +145,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
149145
-i "pandas.Series.to_csv ES01" \
150146
-i "pandas.Series.to_dict ES01" \
151147
-i "pandas.Series.to_frame ES01" \
152-
-i "pandas.Series.to_xarray ES01" \
153148
-i "pandas.Series.to_string ES01" \
154149
-i "pandas.Series.to_markdown ES01" \
155150
-i "pandas.testing.assert_series_equal ES01" \
@@ -484,21 +479,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
484479
-i "pandas.DataFrame.round ES01" \
485480
-i "pandas.DataFrame.value_counts ES01" \
486481
-i "pandas.DataFrame.at_time ES01" \
487-
-i "pandas.DataFrame.rename_axis ES01" \
488-
-i "pandas.DataFrame.ffill ES01" \
489-
-i "pandas.DataFrame.fillna ES01" \
490-
-i "pandas.DataFrame.droplevel ES01" \
491-
-i "pandas.DataFrame.sort_values ES01" \
492-
-i "pandas.DataFrame.explode ES01" \
493-
-i "pandas.DataFrame.to_xarray ES01" \
494-
-i "pandas.DataFrame.T ES01" \
495-
-i "pandas.DataFrame.compare ES01" \
496-
-i "pandas.DataFrame.tz_convert ES01" \
497-
-i "pandas.DataFrame.sparse.density ES01" \
498-
-i "pandas.DataFrame.sparse.from_spmatrix ES01" \
499-
-i "pandas.DataFrame.sparse.to_coo ES01" \
500-
-i "pandas.DataFrame.sparse.to_dense ES01" \
501-
-i "pandas.DataFrame.to_string ES01" \
502482
-i "pandas.DataFrame.to_markdown ES01" # no backslash in the last line
503483

504484
RET=$(($RET + $?)) ; echo $MSG "DONE"

pandas/core/arrays/sparse/accessor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,9 @@ def from_spmatrix(cls, data, index=None, columns=None) -> DataFrame:
310310
"""
311311
Create a new DataFrame from a scipy sparse matrix.
312312
313+
This method converts a scipy sparse matrix into a pandas DataFrame
314+
with sparse array columns for memory efficiency.
315+
313316
Parameters
314317
----------
315318
data : scipy.sparse.spmatrix
@@ -369,6 +372,9 @@ def to_dense(self) -> DataFrame:
369372
"""
370373
Convert a DataFrame with sparse values to dense.
371374
375+
This method converts all SparseArray columns in the DataFrame to
376+
regular NumPy arrays.
377+
372378
Returns
373379
-------
374380
DataFrame
@@ -397,6 +403,9 @@ def to_coo(self) -> spmatrix:
397403
"""
398404
Return the contents of the frame as a sparse SciPy COO matrix.
399405
406+
This method converts the DataFrame to a scipy COO (Coordinate) sparse
407+
matrix format for interoperability with scipy.sparse routines.
408+
400409
Returns
401410
-------
402411
scipy.sparse.spmatrix
@@ -450,6 +459,9 @@ def density(self) -> float:
450459
"""
451460
Ratio of non-sparse points to total (dense) data points.
452461
462+
This property returns the proportion of the data that is not sparse
463+
(i.e., not equal to the fill value), as a value between 0 and 1.
464+
453465
See Also
454466
--------
455467
DataFrame.sparse.from_spmatrix : Create a new DataFrame from a

pandas/core/frame.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,9 @@ def to_string(
10761076
"""
10771077
Render a DataFrame to a console-friendly tabular output.
10781078

1079+
This method converts the DataFrame to a string representation suitable
1080+
for printing or writing to a file.
1081+
10791082
Parameters
10801083
----------
10811084
buf : str, Path or StringIO-like, optional, default None
@@ -4121,6 +4124,9 @@ def T(self) -> DataFrame:
41214124
"""
41224125
The transpose of the DataFrame.
41234126

4127+
This property returns a DataFrame with rows and columns interchanged,
4128+
reflecting the data across the main diagonal.
4129+
41244130
Returns
41254131
-------
41264132
DataFrame
@@ -7987,6 +7993,9 @@ def sort_values(
79877993
"""
79887994
Sort by the values along either axis.
79897995

7996+
This method sorts the DataFrame by the values in one or more columns
7997+
or by index/column labels.
7998+
79907999
Parameters
79918000
----------
79928001
by : str or list of str
@@ -11808,6 +11817,9 @@ def compare(
1180811817
"""
1180911818
Compare to another DataFrame and show the differences.
1181011819

11820+
This method compares two DataFrames element-wise and returns a DataFrame
11821+
highlighting the differences.
11822+
1181111823
Parameters
1181211824
----------
1181311825
other : DataFrame
@@ -13207,6 +13219,9 @@ def explode(
1320713219
"""
1320813220
Transform each element of a list-like to a row, replicating index values.
1320913221

13222+
This method is useful for expanding nested data structures like lists
13223+
into separate rows while maintaining the relationship with other columns.
13224+
1321013225
Parameters
1321113226
----------
1321213227
column : IndexLabel

pandas/core/generic.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,9 @@ def droplevel(self, level: IndexLabel, axis: Axis = 0) -> Self:
770770
"""
771771
Return Series/DataFrame with requested index / column level(s) removed.
772772
773+
This method is useful for simplifying a MultiIndex by removing one or
774+
more levels.
775+
773776
Parameters
774777
----------
775778
level : int, str, or list-like
@@ -1120,6 +1123,9 @@ def rename_axis(
11201123
"""
11211124
Set the name of the axis for the index or columns.
11221125
1126+
This method is useful for labeling the axes in a MultiIndex or for
1127+
providing descriptive names to axes.
1128+
11231129
Parameters
11241130
----------
11251131
mapper : scalar, list-like, optional
@@ -3235,6 +3241,9 @@ def to_xarray(self):
32353241
"""
32363242
Return an xarray object from the pandas object.
32373243
3244+
This method converts a pandas object to an xarray object, which is
3245+
useful for working with labeled multi-dimensional data.
3246+
32383247
Returns
32393248
-------
32403249
xarray.DataArray or xarray.Dataset
@@ -6942,6 +6951,8 @@ def fillna(
69426951
"""
69436952
Fill NA/NaN values with `value`.
69446953
6954+
This method replaces missing values with a specified value.
6955+
69456956
Parameters
69466957
----------
69476958
value : scalar, dict, Series, or DataFrame
@@ -7181,6 +7192,9 @@ def ffill(
71817192
"""
71827193
Fill NA/NaN values by propagating the last valid observation to next valid.
71837194
7195+
This method fills missing values using forward fill, where the last
7196+
valid observation is propagated forward to fill the gaps.
7197+
71847198
Parameters
71857199
----------
71867200
axis : {0 or 'index'} for Series, {0 or 'index', 1 or 'columns'} for DataFrame
@@ -10875,6 +10889,9 @@ def tz_convert(
1087510889
"""
1087610890
Convert tz-aware axis to target time zone.
1087710891
10892+
This method converts the timezone of a datetime-based index from one
10893+
timezone to another.
10894+
1087810895
Parameters
1087910896
----------
1088010897
tz : str or tzinfo object or None

0 commit comments

Comments
 (0)