Пример #1
0
    def test_accessor_works(self):
        register_series_accessor("test")(CustomAccessor)

        s = ks.Series([1, 2])
        assert s.test.obj is s
        assert s.test.prop == "item"
        assert s.test.method() == "item"
Пример #2
0
 def test_overwrite_warns(self):
     mean = ks.Series.mean
     try:
         with assert_produces_warning(UserWarning) as w:
             register_series_accessor("mean")(CustomAccessor)
             s = ks.Series([1, 2])
             assert s.mean.prop == "item"
         msg = str(w[0].message)
         assert "mean" in msg
         assert "CustomAccessor" in msg
         assert "Series" in msg
     finally:
         ks.Series.mean = mean
Пример #3
0
 def test_series_register(self):
     with ensure_removed(ks.Series, "test"):
         register_series_accessor("test")(CustomAccessor)
         assert self.kdf.a.test.prop == "item"
         assert self.kdf.a.test.method() == "item"
         assert self.kdf.a.test.check_length() == len(self.kdf["a"])
Пример #4
0
# pylint: skip-file
# NOTE: skip file since py=3.10 yields these errors:
# https://github.com/pandera-dev/pandera/runs/4998710717?check_suite_focus=true
"""Register koalas accessor for pandera schema metadata."""

from databricks.koalas.extensions import (
    register_dataframe_accessor,
    register_series_accessor,
)

from pandera.pandas_accessor import (
    PanderaDataFrameAccessor,
    PanderaSeriesAccessor,
)

register_dataframe_accessor("pandera")(PanderaDataFrameAccessor)
register_series_accessor("pandera")(PanderaSeriesAccessor)