I find here a way to apply .strip() to all cells in dataframe with multiple data types and thus remove all white space in my dataframe.
file = pd.read_excel('filename.xlsx')
def remove_whitespace( x ):
if isinstance( x, str ):
return x.strip()
else:
return x
my_data = file.applymap( remove_whitespace )
but I get this message, and I don't know/understand how to adapt the code
FutureWarning: Inferring datetime64[ns] from data containing strings is deprecated and will be removed in a future version. To retain the old behavior explicitly pass Series(data, dtype=datetime64[ns])
my_data = fichier_source.applymap( remove_whitespace )