Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Inserting a python list into a dataframe column wise
#1
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"
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  5 python columns, row-wise as input to a function dervast 1 90 Jul-17-2019, 08:53 PM
Last Post: Larz60+
  inserting data to mysql with python justin_py 1 317 Jul-11-2019, 10:13 PM
Last Post: metulburr
  [split] Automate the boring stuff, inserting commas in list srikanth 1 134 Jul-02-2019, 02:29 PM
Last Post: metulburr
  Inserting a variable name into xlabel myersluke 0 131 Jun-19-2019, 10:22 PM
Last Post: myersluke
  Creating a new DataFrame from another DataFrame column Ilangos 1 175 Jun-05-2019, 09:47 AM
Last Post: Ilangos
  Inserting csv values into SQL server vincentwebs 3 247 May-15-2019, 05:25 PM
Last Post: Larz60+
  Automate the boring stuff, inserting commas in list DJ_Qu 3 306 Apr-21-2019, 03:52 PM
Last Post: perfringo
  How get row index of matching row in column 0 Sri 7 388 Apr-10-2019, 08:26 PM
Last Post: perfringo
  Inserting new row into SQLite KevinBrown 5 387 Mar-28-2019, 07:43 PM
Last Post: nilamo
  How to group by name and column in box plot SriRajesh 0 175 Mar-19-2019, 02:33 PM
Last Post: SriRajesh

Forum Jump:


Users browsing this thread: 1 Guest(s)