Demo entry 6363754

test

   

Submitted by anonymous on May 14, 2017 at 17:21
Language: Python 3. Code size: 1.0 kB.

from flexx import ui, app, event
from flexx.pyscript.stubs import window
import pandas as pd

df = pd.DataFrame(data={'A' : [8.0,3.2,4.0,-2.5,3.7],
                        'B' : [7.0,1.1,4.9,3.8,1.2],
                        'C' : [-4.0,5.0,-1.2,-5.4,4.6]})


class Manage_Pandas(ui.Widget):
   
    def init(self):
        self.df = df
        self.col = ui.ComboBox(options=['A', 'B', 'C'])
        self.col.selected_key = 'A'
        self.label = ui.Label()
        meta = {}
        bb = self.df[self.col.selected_key].values.tobytes()
        self.send_data(bb, meta)

        
    @event.connect('col.selected_key')
    def update_data(self, *events):
        new_col = self.col.selected_key
        meta = {}
        bb = self.df[new_col].values.tobytes()
        self.send_data(bb, meta)
      
    class JS:

        def receive_data(self, blob, meta):
            data = window.Float64Array(blob)
            self.label.text = data
        
app.launch(Manage_Pandas, 'chrome-browser')

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).