Giter VIP home page Giter VIP logo

Comments (5)

cosmicBboy avatar cosmicBboy commented on May 30, 2024

Thanks for bringing this up @kernelpernel, would it be possible to provide some screenshots and a minimally reproducible example? Don't really understand what you mean by docs being injected.

from pandera.

kernelpernel avatar kernelpernel commented on May 30, 2024

No screenshots due to possible IP conflicts, but I put together this quick example:

For example, if I write this class:

class ExampleSchema(pa.SchemaModel):
    """Schema to demonstrate doc injection."""

    Column1: sc.Integer = sc.IntegerF()
    Column2: sc.Str = sc.StrF()

I get this output for the sphinx-generated docs:

class jane_dev.options.utils.doc_testing.ExampleSchema(*args, **kwargs)

   Bases: "pandera.api.pandas.model.DataFrameModel"

   Schema to demonstrate doc injection.

   Check if all columns in a dataframe have a column in the Schema.

   Parameters:
      * **check_obj** (*pd.DataFrame*) -- the dataframe to be
        validated.

      * **head** -- validate the first n rows. Rows overlapping with
        "tail" or "sample" are de-duplicated.

      * **tail** -- validate the last n rows. Rows overlapping with
        "head" or "sample" are de-duplicated.

      * **sample** -- validate a random sample of n rows. Rows
        overlapping with "head" or "tail" are de-duplicated.

      * **random_state** -- random seed for the "sample" argument.

      * **lazy** -- if True, lazily evaluates dataframe against all
        validation checks and raises a "SchemaErrors". Otherwise,
        raise "SchemaError" as soon as one occurs.

      * **inplace** -- if True, applies coercion to the object of
        validation, otherwise creates a copy of the data.

   Returns:
      validated "DataFrame"

   Raises:
      **SchemaError** -- when "DataFrame" violates built-in or custom
      checks.

   Example:
   Calling "schema.validate" returns the dataframe.

   >>> import pandas as pd
   >>> import pandera as pa
   >>>
   >>> df = pd.DataFrame({
   ...     "probability": [0.1, 0.4, 0.52, 0.23, 0.8, 0.76],
   ...     "category": ["dog", "dog", "cat", "duck", "dog", "dog"]
   ... })
   >>>
   >>> schema_withchecks = pa.DataFrameSchema({
   ...     "probability": pa.Column(
   ...         float, pa.Check(lambda s: (s >= 0) & (s <= 1))),
   ...
   ...     # check that the "category" column contains a few discrete
   ...     # values, and the majority of the entries are dogs.
   ...     "category": pa.Column(
   ...         str, [
   ...             pa.Check(lambda s: s.isin(["dog", "cat", "duck"])),
   ...             pa.Check(lambda s: (s == "dog").mean() > 0.5),
   ...         ]),
   ... })
   >>>
   >>> schema_withchecks.validate(df)[["probability", "category"]]
      probability category
   0         0.10      dog
   1         0.40      dog
   2         0.52      cat
   3         0.23     duck
   4         0.80      dog
   5         0.76      dog

   Column1: pandera.typing.pandas.Series[pandas.core.arrays.integer.Int64Dtype] = 'Column1'

   Column2: pandera.typing.pandas.Series[str] = 'Column2'

   class Config

      Bases: "pandera.api.pandas.model_config.BaseConfig"

      name: str | None = 'ExampleSchema'

         name of schema

Where I would expect to only see this:

class jane_dev.options.utils.doc_testing.ExampleSchema(*args, **kwargs)

   Bases: "pandera.api.pandas.model.DataFrameModel"

   Schema to demonstrate doc injection.

   Column1: pandera.typing.pandas.Series[pandas.core.arrays.integer.Int64Dtype] = 'Column1'

   Column2: pandera.typing.pandas.Series[str] = 'Column2'

And the docs appear to be the same as those from here:
Pandera Docs

from pandera.

kernelpernel avatar kernelpernel commented on May 30, 2024

Thanks for the quick response @cosmicBboy !

from pandera.

cosmicBboy avatar cosmicBboy commented on May 30, 2024

It's probably because of the __new__ method: https://github.com/unionai-oss/pandera/blob/main/pandera/api/dataframe/model.py#L127-L132

Can you try overriding that method and seeing if it happens?

from pandera.

cosmicBboy avatar cosmicBboy commented on May 30, 2024

@kernelpernel any updates on this issue?

from pandera.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.