Skip to content
Advertisement

How would I find the longest string per row in a data frame and print the row number if it exceeds a certain amount

I want to write a program which searches through a data frame and if any of the items in it are above 50 characters long, print the row number and ask if you want to continue through the data frame.

JavaScript

I tried using this, but I don’t want to drop the rows, just print the row numbers where the strings exceed 50

Input:

JavaScript

Output:

JavaScript

I would also like the program to print the specific value or string which is too long.

Advertisement

Answer

You can use:

JavaScript

Output:

JavaScript

Intermediate s:

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