Skip to content

Allow to pass through columns #100

Open

Description

I have a dataframe with a lot of columns (>100) and would like to not need to specify all of them.
Would it be possiuble to support a strict = False mode and/or to specify types for multiple columns?

Maybe such an api:

class FeaturesForwardModelSchema(dy.Schema):
    claim = dy.String(primary_key=True, nullable=False)
    cost = dy.Int64(primary_key=True, nullable=False)
    dataframely_options: DataframelyOptions(strict=False)

df = pl.DataFrame({
    "claim": ["a"],
    "cost": [1],
    "extra_col": ["foo"],
})

df_validated = FeaturesForwardModelSchema.validate(df)
df_validated["extra_col"]

alternatively, maybe something like this?

FeaturesForwardModelSchema.validate(df, strict=False)

Although this could be quite annoying, needing to specify it every time

Activity

  1. pavelzw commented on Jul 18, 2025

    @pavelzw
    MemberAuthor

    specifying schemas for multiple columns at the same time could be interesting with globs?

  2. DeflateAwning commented on Oct 23, 2025

    @DeflateAwning
    Contributor

    I'd suggest adding an argument to the .validate() method like on_extra_columns: Literal["drop", "raise", "keep_at_end"] = "drop" might be an appropriate way to add support for not silently allowing this. The strict: bool proposed in this issue does not address the 3+ possible behaviours, and creates the start of a challenging-to-upgrade API.

  3. borchero commented on Oct 24, 2025

    @borchero
    Member

    I think the core question to answer is whether this option should live in the schema or be an option to validate (as well as filter and cast). I.e. is this behavior a property of the schema or should it change for every operation. I haven't fully made up my mind yet but I tend to treat it as a property of the schema as, otherwise, code documentation suffers: when encountering the schema in a function signature, it isn't clear whether it may have additional columns or not.

  4. DeflateAwning commented on Oct 25, 2025

    @DeflateAwning
    Contributor

    If you're looking for an opinion, I think that these operations settings should be able to be defined in the schema, and overridden at the .validate() call via kwargs there.

  5. kszlim commented on Nov 19, 2025

    @kszlim

    This would be useful, or even an option in dy.Collection to return untyped LazyFrames? It's not always possible/desirable to specify the data schemas up front everywhere.

  6. mullimanko commented on Nov 20, 2025

    @mullimanko

    As an aside, I would endorse to define a column constraint in a schema that applies to all columns in the dataframe. For example, I would like to check if all values in all columns of a dataframe are > 10.

  7. brendancooley commented on Nov 21, 2025

    @brendancooley

    I think the core question to answer is whether this option should live in the schema or be an option to validate (as well as filter and cast). I.e. is this behavior a property of the schema or should it change for every operation. I haven't fully made up my mind yet but I tend to treat it as a property of the schema as, otherwise, code documentation suffers: when encountering the schema in a function signature, it isn't clear whether it may have additional columns or not.

    Oliver Borchert (@borchero) I think I'd vote the other way. In the following example

    import dataframely as dy
    
    class FooSchema(dy.Schema):
        foo = dy.String(nullable=False)

    We can think of the data frame

    df_with_bar = pl.DataFrame(
        {
            "foo": ["a", "b", "c"],
            "bar": ["d", "e", "f"],
        }
    )

    as implementing (and embellishing) FooSchema. Any expression that you can apply to a frame that strictly implements FooSchema (contains only "foo") you can also apply to df_with_bar (I think). Not my area but LSP yada yada...

    I don't think dataframely currently supports this but it would be neat if we could type df_with_bar as follows

    class BarSchema(dy.Schema):
        bar = dy.String(nullable=False)
    
    df_with_bar: dy.DataFrame[FooSchema & BarSchema] = ...

    Maybe some work needed on python first, but this would make it easy to compose subschemas together to validate dataframes that are the result of joins/etc while retaining the ability to validate the components or validate partially when partial validation is sufficient. I think configuring on the Schema forecloses these patterns.

    Stumbled onto this issue also looking to pass extra columns through validate(..., cast=True), so also support half-measures here. I like DeflateAwning's proposal

    on_extra_columns: Literal["drop", "raise", "keep_at_end"] = "drop"
    

    Some links to current select logic

    def match_to_schema(

    lf = df.lazy().pipe(

  8. mathisdrn commented on Aug 1, 2026

    @mathisdrn
    Contributor

    on_extra_columns: Literal["drop", "raise", "keep_at_end"] = "drop"

    Personal opinion but I would add keep or keep_in_place as an option too.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions