Skip to content
Advertisement

IndexError: single positional indexer is out-of-bounds

I have a dataframe that contains a few rows. I want to access one by one row and create another data frame with specific columns. After that running some other logics but it failed before that.

Dataframe df_input_data

JavaScript

Access row using iterrows():

JavaScript

Output:

JavaScript

Creating another dataframe:

JavaScript

issue is df_src_input is empty.

JavaScript

Is there any other way to assign value to different dataframe.

Advertisement

Answer

if you print out

JavaScript

for example, it will be type <class 'str'>, which is just a string value. To put data in a column, it must be a list or a tuple. Put each value in square brackets.

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