Fix "TypeError: string indices must be integers"

How to convert this string (hover_year = hover_data[‘points’][0][‘x’]) indices into integers?

    else:
     print(f'hover data: {hover_data}')
     terr4 = terr.groupby(['country_txt', 'region_txt', 'provstate', 'city', 'iyear', 'latitude', 'longitude'])[['nkill', 'nwound']].sum().reset_index()
     hover_year = hover_data['points'][0]['x']
     terr6 = terr4[(terr4['country_txt'] == select_country) & terr4[(terr4['iyear'] == hover_year)]]

I am trying to filter data using point value. Please fix this.

All the characters of a string have a unique index . This index specifies the position of each character of the string. TypeError: string indices must be integers means an attempt to access a location within a string using an index that is not an integer.

For example, str[hello"] and str[2.1] as indexes. As these are not integers, a TypeError exception is raised. This means that when you’re accessing an iterable object like a string or float value, you must do it using an integer value .

Python supports slice notation for any sequential data type like lists, strings , tuples, bytes, bytearrays, and ranges. When working with strings and slice notation, it can happen that a TypeError: string indices must be integers is raised, pointing out that the indices must be integers, even if they obviously are.