Mar-04-2019, 11:44 PM
I have the following python list,
<TICKER><DTYYYYMMDD><CLOSE><TICKER><DTYYYYMMDD><CLOSE>
'CVM' 20010619 332.5 'AEF' 19970102 18.7489
'CVM' 20010620 330.0 'AEF' 19970103 18.9735
'CVM' 20010621 342.5 'AEF' 19970106 19.5348
'CVM' 20010622 337.5 'AEF' 19970107 19.6471
I use the following code:
test_list = [ ['CVM', 20010618, 332.5], ['CVM', 20010619, 332.5], ['CVM', 20010620, 330.0], ['CVM', 20010621, 342.5], ['CVM', 20010622, 337.5], ['AEF', 19970102, 18.7489], ['AEF', 19970103, 18.9735], ['AEF', 19970106, 19.5348], ['AEF', 19970107, 19.6471] ]I want to concat it into a dataframe with axis=1, so it would be like that in the dataframe
<TICKER><DTYYYYMMDD><CLOSE><TICKER><DTYYYYMMDD><CLOSE>
'CVM' 20010619 332.5 'AEF' 19970102 18.7489
'CVM' 20010620 330.0 'AEF' 19970103 18.9735
'CVM' 20010621 342.5 'AEF' 19970106 19.5348
'CVM' 20010622 337.5 'AEF' 19970107 19.6471
I use the following code:
frame = pd.concat(test_list, axis=1, ignore_index=True)but I get the following error "TypeError: cannot concatenate object of type "<class 'list'>"; only pd.Series, pd.DataFrame, and pd.Panel (deprecated) objs are valid"