Skip to content
Advertisement

calling list() method over array of one element raises TypeError: iteration over a 0-d array

calling list() method over pandas dataframe single row raises an error. For example,

JavaScript

Now, the below is fine

JavaScript

but,

JavaScript

raises:

JavaScript

How to address this issue?

Advertisement

Answer

You can use pd.Series.tolist() here.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement