Commit 611419d0 authored by Levin Zimmermann's avatar Levin Zimmermann

erp5_data_notebook += test un/pickle pd.DF=>np.rec

Add test which verifies that we can un/pickle 'pd.DataFrame' which were
converted to 'np.recarray' via the '.to_records()' method.

This test is necessary because it turns out that the combination of
pandas >= 0.20.x + python2 doesn't support this functionality by
default if the data frames column names are unicodes.

Please see nexedi/erp5!1738 (comment 179298) for
additional context.

/reviewed-on nexedi/erp5!1738
/reviewed-by @jerome @klaus
parent f8301a19
......@@ -35,6 +35,8 @@ import jupyter_client
import base64
import random
import string
import pickle
import pandas as pd
class TestExecuteJupyter(ERP5TypeTestCase):
......@@ -1067,3 +1069,16 @@ print os.path
else:
has_access_to_erp5_kernel = True
self.assertTrue(has_access_to_erp5_kernel)
def testConvertedDataFramesArePicklableAndUnpicklable(self):
'''
Verify we can pickle + unpickle pd.DataFrames which were converted to np.recarrays
'''
self.assertEqual(
pickle.loads(
pickle.dumps(
pd.DataFrame(columns=[u"test"]).to_records()
)
).dtype.descr[1][0],
"test"
)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment