#-----------------------------------------------------------------------------# Copyright (c) 2012 - 2022, Anaconda, Inc., and Bokeh Contributors.# All rights reserved.## The full license is in the file LICENSE.txt, distributed with this software.#-----------------------------------------------------------------------------""" Provide (optional) Pandas properties."""#-----------------------------------------------------------------------------# Boilerplate#-----------------------------------------------------------------------------from__future__importannotationsimportlogging# isort:skiplog=logging.getLogger(__name__)#-----------------------------------------------------------------------------# Imports#-----------------------------------------------------------------------------# Bokeh importsfrom...util.dependenciesimportimport_optionalfrom.basesimportProperty#-----------------------------------------------------------------------------# Globals and constants#-----------------------------------------------------------------------------pd=import_optional('pandas')__all__=('PandasDataFrame','PandasGroupBy',)#-----------------------------------------------------------------------------# General API#-----------------------------------------------------------------------------
[docs]classPandasDataFrame(Property):""" Accept Pandas DataFrame values. This property only exists to support type validation, e.g. for "accepts" clauses. It is not serializable itself, and is not useful to add to Bokeh models directly. """defvalidate(self,value,detail=True):super().validate(value,detail)ifpdandisinstance(value,pd.DataFrame):returnmsg=""ifnotdetailelsef"expected Pandas DataFrame, got {value!r}"raiseValueError(msg)
[docs]classPandasGroupBy(Property):""" Accept Pandas DataFrame values. This property only exists to support type validation, e.g. for "accepts" clauses. It is not serializable itself, and is not useful to add to Bokeh models directly. """defvalidate(self,value,detail=True):super().validate(value,detail)ifpdandisinstance(value,pd.core.groupby.GroupBy):returnmsg=""ifnotdetailelsef"expected Pandas GroupBy, got {value!r}"raiseValueError(msg)
#-----------------------------------------------------------------------------# Dev API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Private API#-----------------------------------------------------------------------------#-----------------------------------------------------------------------------# Code#-----------------------------------------------------------------------------