Finding the column in a Pandas DataFrame that contains a list with only one element
import pandas as pd
# Example DataFrame with a column containing lists
df = pd.DataFrame({'Column1': [[1, 2], [3], [4, 5]], 'Column2': [[6, 7], [8, 9], [10]]})
# Find the column with lists of length 1
result = df.apply(lambda x: x.str.len() == 1).a...
hashnotes.hashnode.dev2 min read