Skip to content

how to define a DataFrameModel that can have arbitrary number of columns but each of them should be float. #1210

Answered by cosmicBboy
rja172 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @rja172 you can use the regex=True combined with alias=... arguments

class FloatSchema(pa.DataFrameModel):
   col: pa.Series[float] = pa.Field(regex=True, alias=".+")

Or you can specify the type at the dataframe-level with a Config class

class FloatSchema(pa.DataFrameModel):
    class Config:
        dtype = float

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ragrawal
Comment options

Answer selected by cosmicBboy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants