# Updating data to dash table

**URL:** <https://community.plotly.com/t/updating-data-to-dash-table/7824>\
**Category:** Dash Python\
**Created:** [January 19, 2018, 2:43pm UTC](https://community.plotly.com/t/updating-data-to-dash-table/7824 "2018-01-19T14:43:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rishikesh\_007](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@Rishikesh\_007](https://community.plotly.com/u/Rishikesh_007)\
**Post date:** [January 19, 2018, 2:43pm UTC](https://community.plotly.com/t/updating-data-to-dash-table/7824/1 "2018-01-19T14:43:37Z")

</div>

I am trying to get data from a csv and display it using dash table. I want to interact with one column and then changing another column accordingly (Subtracting value of ‘manual input’ column from ‘recommended’ column and storing the answer to ‘available’ column)

I have got the result of subtractions and can view the data frame on cmd but I do not understand how to write it to Output of Callback function and after trying following code it shows error loading dependencies.

![Q1](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/9/9cf4c6027c4b88839e53ae772a0d27af3b8428c2.PNG)

DF= pd.read\_csv(  
‘data.csv’  
)

app.layout = html.Div(children=[  
html.H4(‘Manual recommendation’),  
html.Div([  
html.Div(id=‘Table’,children=  
dt.DataTable(  
rows=DF.to\_dict(‘records’),  
filterable=True,  
sortable=True,  
selected\_row\_indices=[],  
id=‘edit-table’,  
),  
),  
]),  
],)

@app.callback(Output(‘edit-table’, ‘rows’),  
[Input(‘edit-table’, ‘rows’)],  
)

def update\_table(rows):  
df = pd.DataFrame(rows)  
df[‘available’] = df[‘recommendation’].astype(int) - df[‘manual input’].astype(int)  
return df

---

<div class="post-metadata">

**Author:** ![ldavy](https://avatars.discourse-cdn.com/v4/letter/l/a6a055/32.png) [@ldavy](https://community.plotly.com/u/ldavy)\
**Post date:** [January 22, 2018, 9:03pm UTC](https://community.plotly.com/t/updating-data-to-dash-table/7824/2 "2018-01-22T21:03:13Z")

</div>

You don’t need to use a callback, just create your dataframe and then pass it in the ‘rows’ attribute of dt.DataTable  
Callback would be usefull only if you wish to dynamically change your datatable.

---

<div class="post-metadata">

**Author:** ![Rishikesh\_007](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@Rishikesh\_007](https://community.plotly.com/u/Rishikesh_007)\
**Post date:** [January 23, 2018, 8:37am UTC](https://community.plotly.com/t/updating-data-to-dash-table/7824/3 "2018-01-23T08:37:00Z")

</div>

Actually I am willing to make dynamic changes on data.  
Initially I have a dataframe like this: ![Q2](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/a/a5163081d1b7c513f2a435b0d32b786a553bdd64.PNG)  
which I am displaying in ‘rows’ attribute of dt.Datatable.

Now I want to enter numbers in ‘manual input’ column which should call the callback function and after making calculations ( subtraction : “df[‘available slots’] = df[‘recommendation rounded’].astype(int) - df[‘manual input’].astype(int)”) I want to display complete dataframe in the same rows attribute of that table.  
I am confused about the ‘Output’ and ‘Input’ of callbacks because the table id will be same and also rows attribute will be same in Output and Input of callback as I am taking input from a table and want to print output to that same table.
