Skip to content

Commit 7af0a18

Browse files
authored
DOC improve inline comment for __dataframe__ support in _get_feature_names (scikit-learn#26664)
1 parent 5a8a574 commit 7af0a18

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

sklearn/utils/validation.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,9 +2024,15 @@ def _get_feature_names(X):
20242024
if _is_pandas_df(X):
20252025
# Make sure we can inspect columns names from pandas, even with
20262026
# versions too old to expose a working implementation of
2027-
# __dataframe__.column_names().
2028-
# TODO: remove once the minimum supported version of pandas has
2029-
# a working implementation of __dataframe__.column_names().
2027+
# __dataframe__.column_names() and avoid introducing any
2028+
# additional copy.
2029+
# TODO: remove the pandas-specific branch once the minimum supported
2030+
# version of pandas has a working implementation of
2031+
# __dataframe__.column_names() that is guaranteed to not introduce any
2032+
# additional copy of the data without having to impose allow_copy=False
2033+
# that could fail with other libraries. Note: in the longer term, we
2034+
# could decide to instead rely on the __dataframe_namespace__ API once
2035+
# adopted by our minimally supported pandas version.
20302036
feature_names = np.asarray(X.columns, dtype=object)
20312037
elif hasattr(X, "__dataframe__"):
20322038
df_protocol = X.__dataframe__()

0 commit comments

Comments
 (0)