holoviz / holoviz/hvplot

.interactive dataframe slice selection by row index or position not possible

Open
#771 22 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
124
Avg merge
1d 18h
Merged PRs (30d)
1

Description

#### Is your feature request related to a problem? Please describe.
I was in the assumption that the .interactive interface for dataframes should mimic the interface of pandas. Yet not everything seems to work.

Given the code
```python
import hvplot.pandas
import panel.widgets as pnw
from bokeh.sampledata import airports
df = airports.data
dfi = df.interactive()

p = pnw.IntSlider(start=10, end=40)
dfi[5:p]
```
I would like to see a slider and a dynamic dataframe representation showing index 5...p-1 (that dataframe has an integer index). Instead I get a static output without slider. I can make one in another cell, but when I move it, the dataframe output does not update. I need to execute the cell manually again to get the update.

This here doesn't work at all and gives an InvalidIndexError
```python
dfi.loc[5:p,:]
# InvalidIndexError: IntSlider(end=40, start=10, value=10)
```

Those here give no slider and don't update when I create a slider in another cell:
```python
dfi.loc[:p]

dfi.iloc[5:p]
dfi.iloc[slice(5,p)]
dfi.values[5:p]
```

This here gives a type error
```python
dfi.loc[dfi.index[5:p]]
# TypeError: slice indices must be integers or None or have an __index__ method
```

A current workaround for `dfi.loc[5:p,:]` is:
```python
dfi[(dfi.index>=5) & (dfi.index

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.