gpt4 book ai didi

python-3.x - 属性错误 : module 'matplotlib' has no attribute 'scatter'

转载 作者:行者123 更新时间:2023-12-03 18:32:16 29 4
gpt4 key购买 nike

我正在尝试制作纬度和经度的集群。
代码在 plt.scatter(data['Lng'],data['Lat']) 中给出了错误线

错误是:

AttributeError: module 'matplotlib' has no attribute 'scatter' 

代码:
import numpy as np
import pandas as pd
import matplotlib as plt
import seaborn as sns
sns.set()
from sklearn.cluster import KMeans
data = pd.read_csv("pk.csv")
data.head()
lat_long = data.drop(['country', 'iso2','admin', 'capital','population',
'population_proper'] , axis = 1)
lat_long.head()
plt.scatter(data['Lng'],data['Lat']) # error here

最佳答案

它应该是:

import matplotlib.pyplot as plt

关于python-3.x - 属性错误 : module 'matplotlib' has no attribute 'scatter' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58540629/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com