Skip to content

Commit ae04f1a

Browse files
levinzimmermannnfdiary
authored andcommitted
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 https://lab.nexedi.com/nexedi/erp5/merge_requests/1738#note_179298 for additional context. /reviewed-on https://lab.nexedi.com/nexedi/erp5/merge_requests/1738 /reviewed-by @jerome @klaus
1 parent d7f8933 commit ae04f1a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

bt5/erp5_data_notebook/TestTemplateItem/portal_components/test.erp5.testExecuteJupyter.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import base64
3636
import random
3737
import string
38+
import pickle
39+
import pandas as pd
3840

3941

4042
class TestExecuteJupyter(ERP5TypeTestCase):
@@ -1067,3 +1069,16 @@ def testERP5hasAccessToERP5Kernel(self):
10671069
else:
10681070
has_access_to_erp5_kernel = True
10691071
self.assertTrue(has_access_to_erp5_kernel)
1072+
1073+
def testConvertedDataFramesArePicklableAndUnpicklable(self):
1074+
'''
1075+
Verify we can pickle + unpickle pd.DataFrames which were converted to np.recarrays
1076+
'''
1077+
self.assertEqual(
1078+
pickle.loads(
1079+
pickle.dumps(
1080+
pd.DataFrame(columns=[u"test"]).to_records()
1081+
)
1082+
).dtype.descr[1][0],
1083+
"test"
1084+
)

0 commit comments

Comments
 (0)