conf_df = conf_df.drop(columns=conf_df.iloc[:, 2:552])
conf_df = conf_df[['Country/Region','7/24/22']]
conf_df.set_index('Country/Region', inplace=True)
conf_df
Country/Region 7/24/22
Afghanistan 184587
Albania 293917
Algeria 266839
Andorra 45326
Angola 102301
... ...
West Bank and Gaza 672039
Winter Olympics 2022 535
Yemen 11849
Zambia 328550
Zimbabwe 256254
285 rows × 1 columns
kmeans = KMeans(n_clusters=3, init='k-means++', random_state=42)
y_kmeans = kmeans.fit_predict(x)
fig, ax = plt.subplots(figsize=(30, 15))
plt.plot(kmeans, y_kmeans )
plt.set_xlabel('Дни года')
plt.set_ylabel('Кол-во заразившихся, тыс')
plt.set_title('График заразившихся')
plt.show()```
Ошибка:
3 frames
/usr/local/lib/python3.7/dist-packages/matplotlib/axes/_base.py in _plot_args(self, tup, kwargs)
340
341 if x.shape[0] != y.shape[0]:
--> 342 raise ValueError(f"x and y must have same first dimension, but "
343 f"have shapes {x.shape} and {y.shape}")
344 if x.ndim > 2 or y.ndim > 2:
ValueError: x and y must have same first dimension, but have shapes (1,) and (285,)