Skip to content

add an object selector to skrub.selectors#2171

Open
omkar-334 wants to merge 2 commits into
skrub-data:mainfrom
omkar-334:s-object
Open

add an object selector to skrub.selectors#2171
omkar-334 wants to merge 2 commits into
skrub-data:mainfrom
omkar-334:s-object

Conversation

@omkar-334

@omkar-334 omkar-334 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #2124.

Adds skrub.selectors.object(), a selector that picks columns whose dtype is object (pandas) or pl.Object (polars).

The selector is a thin wrapper around the existing sbd.is_object dispatch (skrub/_dataframe/_common.py:868).

Checklist

  • I have read the contributing guidelines
  • I have added tests that verify the bug fix
  • I have added an entry to CHANGES.rst describing the fix
  • My code follows the code style of this project
  • I have checked my code and corrected any misspellings

How Has This Been Tested?

Test script from skrub import selectors as s import pandas as pd import polars as pl

def demo_pandas():
print("=== pandas frame ===")
df = pd.DataFrame(
{
"mixed": pd.Series(["a", 1]),
"numeric": [1, 2],
"ext_string": pd.Series(["a", "b"]).convert_dtypes(),
}
)
print("dtypes:")
print(df.dtypes.to_string())
selected = s.select(df, s.object()).columns.tolist()
print("s.object() selected:", selected)
print()

def demo_polars():
print("=== polars frame ===")
df = pl.DataFrame(
{
"obj": pl.Series([object(), object()], dtype=pl.Object),
"str": ["a", "b"],
"num": [1, 2],
}
)
print("schema:", df.schema)
selected = s.select(df, s.object()).columns
print("s.object() selected:", selected)
print()

demo_pandas()
demo_polars()

Screenshot 2026-06-17 at 3 21 16 AM

AI Disclosure

  • This PR contains AI-generated code
    • I have tested the code generated in my PR
    • I have read and understood every line that has been generated by the AI agent
    • I can explain what the AI-generated code does

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FEAT - Add a "s.object()" selector

1 participant