python-3.xmatplotlibscatter

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


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

Solution

  • It should be:

    import matplotlib.pyplot as plt