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

Osama Billah picture Osama Billah · Oct 24, 2019 · Viewed 10.4k times · Source

I'm trying to make cluster of latitude and longitude. the code gave an error in plt.scatter(data['Lng'],data['Lat']) line

the error is:

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

code:

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

Answer

Franco Piccolo picture Franco Piccolo · Oct 24, 2019

It should be:

import matplotlib.pyplot as plt