How do I hide a column of a data table from being displayed, but use that column for filtering and sorting?

I have a data table with a Price column as follows:

However, since the price contains a $ and some more strings (at Amazon, etc), and I want to display it as such, I created a Price_New column by stripping these strings and making it an integer column. I am using the Price_New column to filter and sort the data table. Is it possible to hide it from being displayed?

hi @kristada619
Welcome back to the community Forum.

One option is to not include it in the DataTable columns, similar to how I removed the Pressure column below:

from dash import Dash, dash_table
import pandas as pd
from collections import OrderedDict

data = OrderedDict(
    [
        ("Date", ["2015-01-01", "2015-10-24", "2016-05-10", "2017-01-10", "2018-05-10", "2018-08-15"]),
        ("Region", ["Montreal", "Toronto", "New York City", "Miami", "San Francisco", "London"]),
        ("Temperature", [1, -20, 3.512, 4, 10423, -441.2]),
        ("Humidity", [10, 20, 30, 40, 50, 60]),
        ("Pressure", [2, 10924, 3912, -10, 3591.2, 15]),
    ]
)
df = pd.DataFrame(data)

app = Dash(__name__)

app.layout = dash_table.DataTable(
    data=df.to_dict('records'),
    columns=[{'id': c, 'name': c} for c in df.columns if c!="Pressure"]
)

if __name__ == '__main__':
    app.run_server(debug=True)

Or you can automatically hide it, but it will still give the user the capability to unhide, I think.

from dash import Dash, html, dash_table
import pandas as pd
from collections import OrderedDict

data = OrderedDict(
    [
        ("Date", ["2015-01-01", "2015-10-24", "2016-05-10", "2017-01-10", "2018-05-10", "2018-08-15"]),
        ("Region", ["Montreal", "Toronto", "New York City", "Miami", "San Francisco", "London"]),
        ("Temperature", [1, -20, 3.512, 4, 10423, -441.2]),
        ("Humidity", [10, 20, 30, 40, 50, 60]),
        ("Pressure", [2, 10924, 3912, -10, 3591.2, 15]),
    ]
)
df = pd.DataFrame(data)

app = Dash(__name__)

app.layout = html.Div([
    html.Div(id='placeholder'),

    dash_table.DataTable(
    id="my-table",
    data=df.to_dict('records'),
    columns=[{'id': c, 'name': c} if c!="Pressure" else {'id': c, 'name': c, "hideable":True} for c in df.columns],
    hidden_columns=['Pressure']
    )
])


if __name__ == '__main__':
    app.run_server(debug=True)