`datestartswith` requires stringified date instead of just a date
See original GitHub issueI’d like to write {Date received} datestartswith 2015
but instead I have to write {Date received} datestartswith "2015"
Example:
import dash
from dash.dependencies import Input, Output
import dash_html_components as html
import dash_core_components as dcc
from dash_table import DataTable
import json
import pandas as pd
import textwrap
url = ("https://github.com/plotly/datasets/raw/master/"
"26k-consumer-complaints.csv")
types = {
'id': 'numeric',
'ZIP code': 'text',
'Date received': 'datetime',
'Date sent to company': 'datetime',
}
df = pd.read_csv(url)
df['id'] = df['Unnamed: 0']
df = df.drop(['Unnamed: 0'], axis=1)
df = df.reindex(columns=['id']+df.columns[:-1].tolist())
app = dash.Dash(__name__)
app.scripts.config.serve_locally = True
app.layout = ddk.App([
dcc.Textarea(
id='filter-input',
style={'width': '100%', 'height': '150px'},
value='{id} > 5'
# value=textwrap.dedent(
# '''
# {id} > 100 and
# ({State} = TX or {State} = NJ) and
# {Date received} = {Date sent to company} and
# {Product} contains Debt and
# {Date received} datestartswith "2015-02"
# ''')
),
dcc.RadioItems(
id='output-type',
options=[
{'label': i, 'value': i} for i in ['Filter', 'Highlight']
],
value='Highlight'
),
html.Div(
children=DataTable(
id='demo-table',
data=df.to_dict('rows'),
columns=[{ 'id': i, 'name': i, 'type': types.get(i, 'any') } for i in df.columns],
filtering=True,
pagination_mode=False,
virtualization=True,
style_data={
'width': '200px'
},
style_table={
'height': 'calc(100vh - 200px)'
}
),
)
])
@app.callback(
[Output('demo-table', 'filter'),
Output('demo-table', 'style_data_conditional')],
[Input('output-type', 'value'),
Input('filter-input', 'value')])
def update_filter(output_type, value):
value = value.strip()
if output_type == 'Filter':
return [value, []]
else:
return ['', [{
'if': {
'filter': value,
},
'backgroundColor': 'hotpink'
}]]
if __name__ == "__main__":
app.run_server(port=8080, debug=True)
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
javascript - Issues with Date() when using JSON.stringify() and ...
It's just basic math but I seem to have some issues with that while using JSON.stringify() and JSON.parse() . If you're wondering why...
Read more >Working with datetime as string - MongoDB
Let's say some external component inserts data into my database, with a field called “startDate”. They store this value as an ISO 8601 ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Right yeah,
{temperature} * 9 / 5 - 32 > 0
or w/eNot so useful in that exact case (arithmetic with literals) but if one part of the expression is a field you could do lots of cool things