Andres Võsa
Andres Võsa

Reputation: 11

ipywidgets and pandas dataframe

How I can get dataframe out of @interact function for next cell? My interact function looks something like this:

@interact(eutPlace=eutPlaces)
def selectByEut (eutPlace):
    rdsTable = tabelSisse.drop(['Id', 'Serial_number', 'User_modified'], axis='columns')
    rdsTable = rdsTable.loc[rdsTable['EUT_place'] == eutPlace]
    print(rdsTable.shape)
    return rdsTable

Upvotes: 0

Views: 121

Answers (1)

Andres Võsa
Andres Võsa

Reputation: 11

Found one solution. Use interactive instead of @interact.

def selectByEut (eutPlace):
    rdsTable = tabelSisse.drop(['Id', 'Serial_number', 'User_modified'], axis='columns')
    rdsTable = rdsTable.loc[rdsTable['EUT_place'] == eutPlace]
    display(rdsTable)
    return rdsTable

intrFilt = interactive(selectByEut, eutPlace=eutPlaces)
intrFilt

And in the next cell i can get the resulting dataframe with:

reducedTable = intrFilt.result

Upvotes: 1

Related Questions