0

I am using pandas to read a csv file and return me a list of the values, and it gives me a list like this(e.g):

[['TSLA'], ['AAPL']] and so on.

I need to read through this list but python complains (ValueError: The truth value of a Series is ambiguous.)

Now, it works fine if I manually type a list this way: ['TSLA', 'AAPL']

So I am trying to find a way to convert my list from [[''],[''],[''],['']] to ['','','',''].

Any leads? I have been searching workarounds and so far I got nowhere. I hope my explanation is clear, as I am still a beginner in python.

Cheers

  • 1
    Welcome to Stackoverflow. Please take the time to read this post on [how to provide a great pandas example](http://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) as well as how to provide a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) and revise your question accordingly. These tips on [how to ask a good question](http://stackoverflow.com/help/how-to-ask) may also be useful. – jezrael Oct 21 '20 at 09:58
  • ```lst = [j[0] for j in lst]``` – Abhinav Mathur Oct 21 '20 at 10:02
  • Does this answer ur question: https://stackoverflow.com/questions/952914/how-to-make-a-flat-list-out-of-list-of-lists – Sushil Oct 21 '20 at 10:25
  • Thanks @AbhinavMathur, that worked!! – Douglas Pasini Oct 21 '20 at 20:27

0 Answers0