Inserting a python list into a dataframe column wise - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Inserting a python list into a dataframe column wise (/thread-16553.html) |
Inserting a python list into a dataframe column wise - mahmoud899 - Mar-04-2019 I have the following python list, 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" |