dcc.Store - dataframe conversion to dict then from dict to dataframe - datetime column becomes an object - why?

Hi there;
I have a dataframe containing one datetime column:

>>dfa["Date"]
...
987   2023-04-09
988   2023-04-16
Name: Date, Length: 989, dtype: datetime64[ns]

I want to store several dataframe like this one, into a dcc.Store. So, let’s build a dict of dict, as below:

#2x dfa below for the sake of simplicity
dictOfDicts={"dfa":dfa.to_dict("records"), "dfb":dfa.to_dict("records")}  

And because I’m trying to figure out what’s going on with my code, let’s do the exact inverse operation, that is, extract the dataframe dfa from this dictOfDicts, and check the “Date” column:

dfa_fromdictOfDicts = pd.DataFrame.from_dict(dictOfDicts["dfa"])
print("___________________________________________________________________________________________")
print(dfa_fromdictOfDicts["Date"])
print("___________________________________________________________________________________________")

As expected, I get:

>>dfa["Date"]
...
987   2023-04-09
988   2023-04-16
Name: Date, Length: 989, dtype: datetime64[ns]

So, at this point, it’s 100% sure that everything is OK when dictOfDicts is sent to the dcc.Store

But, consider the below callback, which retrieve data from the dcc.Store:

@app.callback(Output('pipeline-order-status-data', 'children'), Input("memory", "data"))
def test(data):
    print(len(data))   #-> will show 2
    print(type(data))  #-> will show dict
    print(data.keys())  #-> will show "dfa" and "dfb"
    print(pd.DataFrame.from_dict(data["dfa"])["Date"])   # will show....not a datetime anymore (!)
    return html.Div([])  # some random stuff just so that the callback is properly executed

Then, the console shows:

2  #OK
<class 'dict'>  #OK
dict_keys(['dfa', 'dfb'])  #OK

and, the annoying part:

987    2023-04-09T00:00:00
988    2023-04-16T00:00:00
Name: Date, Length: 989, dtype: object  # WHY?

Why do I now get an object column, rather than the initial datetime ? :thinking: :thinking: :thinking: