python - How to identify columns which contain only tuples in Pandas? - Stack Overflow

PHOTO EMBED

Wed Mar 15 2023 07:25:12 GMT+0000 (Coordinated Universal Time)

Saved by @hardikraja #python

for i in df.columns:
    print ('column :',i, 'is a tuple : ', all(isinstance(x,tuple) for x in df[i]))
content_copyCOPY

If you want to check for all the columns in the dataframe, you can give something like this:

https://stackoverflow.com/questions/64778883/how-to-identify-columns-which-contain-only-tuples-in-pandas