def clear(df):
array = df.values
for n,i in enumerate(array):
for k,j in enumerate(i):
if type(j) == str:
try:
j.decode('ascii')
except:
array[n][k] = j.decode('utf-8')
else:
array[n][k] = j.encode('utf-8')
return pd.DataFrame(array)
Last active
August 29, 2015 14:21
-
-
Save hellpanderrr/cec438049e7e9e0591f5 to your computer and use it in GitHub Desktop.
Python pandas clean bad encoding in a data frame
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment