У меня проблема с попыткой очистить вики-страницу, чтобы получить окрестности списка Торонто, используя Python
import wikipedia
Riding_neighborhood_df = pd.DataFrame()
for item in riding_list:
section = wikipedia.page(item).section('Geography')
start = section.index('neighbourhoods of')
stop = section.index('.',start)
Riding_neighborhood_df = Riding_neighborhood_df.append({'Riding':item,
'Neighborhoods':section[start:stop]},ignore_index=True)
Riding_neighborhood_df = Riding_neighborhood_df[['Riding','Neighborhoods']]
Riding_neighborhood_df
Я получаю следующую ошибку:
AttributeErrorTraceback (most recent call last)
<ipython-input-73-aa1026695246> in <module>
5 for item in riding_list:
6 section = wikipedia.page(item).section('Geography')
----> 7 start = section.index('neighborhoods')
8 stop = section.index('.',start)
9 Riding_neighborhood_df =
Riding_neighborhood_df.append({'Riding':item, '
Neighborhoods':section[start:stop]},ignore_index=True)
AttributeError: 'NoneType' object has no attribute 'index'