EDIT: I need to access the ds data and normalize the text. I tried changing json to df to try some functions I found but no success. In the end it doesn't matter if I have a dataframe, json... The main issue is to able to normalize the text.
From the following =
data = [
{
"id": 504,
"ds": "A description with ressonância magnética"
},
{
"id": 505,
"ds": "Another description that contains word with accentuation"
}]
I'm changing it to a pandas DataFrame
df = pd.DataFrame(data)
print(df['ds'])
And I try to access df['ds'] to use .apply(unicodedata.normalize('NFKD', df['ds']) because I need to remove all words with any type of accentuation, eg. 'à', 'â', 'ã', etc.
But I get 'AttributeError: 'str' object has no attribute 'apply''
Other thing I tried was
def remove_accents(input_str):
nfkd_form = unicodedata.normalize('NFKD', input_str)
only_ascii = nfkd_form.encode('ASCII', 'ignore')
return only_ascii
df['ds'] = df['ds'].apply(remove_accents)
But I get the error 'TypeError: normalize() argument 2 must be str, not bytes'
I'm new to python so forgive me lol But I've tried many things.
Any help is appreciated!