booleandf = pandasDF.select_dtypes(include=[bool])
booleanDictionary = {True: 'TRUE', False: 'FALSE'}
for column in booleandf:
pandasDF[column] = pandasDF[column].map(booleanDictionary)
pandasDF = pd.DataFrame({'A':[True,False,True],
'B':[4,5,6],
'C':[False,True,False]})
print (pandasDF)
A B C
0 True 4 False
1 False 5 True
2 True 6 False
booleandf = pandasDF.select_dtypes(include=[bool])
booleanDictionary = {True: 'TRUE', False: 'FALSE'}
#loop by df is loop by columns, same as for column in booleandf.columns:
for column in booleandf:
pandasDF[column] = pandasDF[column].map(booleanDictionary)
print (pandasDF)
A B C
0 TRUE 4 FALSE
1 FALSE 5 TRUE
2 TRUE 6 FALSE
booleanDictionary = {True: 'TRUE', False: 'FALSE'}
pandasDF = pandasDF.replace(booleanDictionary)
print (pandasDF)
A B C
0 TRUE 4 FALSE
1 FALSE 5 TRUE
2 TRUE 6 FALSE