You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried multiple times to format datetime because I want to avoid displaying NaT and I find it impossible despite trying in many different ways.
If it wasn't for NA I could have just used TextRenderer(format='%Y%B%d', format_type='time')
Here is a simple example:
import pandas as pd
from ipydatagrid import TextRenderer, DataGrid
from py2vega.functions.type_coercing import toDate
from py2vega.functions.formatting import timeFormat, timeParse
from py2vega.functions.type_checking import isValid, isDate, isString
def format_date(cell):
if not isValid(cell.value):
return '-'
else:
return timeFormat(toDate(cell.value), '%Y%B%d')
date = pd.date_range(start='20221010', periods=10, name='date').to_frame().reset_index(drop=True)
date.iloc[0,0] = np.nan
DataGrid(
date,
default_renderer=TextRenderer(text_value=Expr(format_date))
)