How to param.DataFrame populated

I am confused on param.DataFrame
I tried this:

df_hast_param = param.DataFrame( columns=['lon', 'lat', 'ili_ismi', 'yas_2', 'tanim', 'ivmval', 'ismi_ivm_jeo'] )

But I don’t know how it is populated with a pandas dataframe.


1 Like

Hi @Ahmet

I don’t know exactly what you are trying to achieve. But this example might help

import param

import pandas as pd

class MyApp(param.Parameterized):
    value = param.DataFrame(columns=["x", "y"])

valid_data = pd.DataFrame({"x": [1,2,3], "y": [1,2,3]})
app = MyApp(value=valid_data)

invalid_data = pd.DataFrame({"x": [1,2,3]})
app.value = invalid_data
$ python ''
Traceback (most recent call last):
  File "C:\repos\private\holoviews\", line 12, in <module>
    app.value = invalid_data
  File "C:\Users\masma\Anaconda3\envs\holoviews_dev\lib\site-packages\param\", line 369, in _f  
    return f(self, obj, val)
  File "C:\Users\masma\Anaconda3\envs\holoviews_dev\lib\site-packages\param\", line 1197, in __set__
  File "C:\Users\masma\Anaconda3\envs\holoviews_dev\lib\site-packages\param\", line 1558, in _validate
    raise ValueError(msg.format(found=list(val.columns), expected=sorted(self.columns)))
ValueError: Provided DataFrame columns ['x'] does not contain required columns ['x', 'y']

If you need more help please provide a minimum, reproducible example that can help the community understand you need. Thanks.