5

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
desertnaut
  • 57,590
  • 26
  • 140
  • 166
Osama Billah
  • 73
  • 1
  • 1
  • 8
  • This is a standard Matplotlib question, and has nothing to do with `machine-learning`, `k-means`, or `artificial-intelligence` (!) - kindly do not spam irrelevant tags (removed & replaced with `matplotlib`, which is surprisingly missing, despite the title). – desertnaut Oct 24 '19 at 15:28

2 Answers2

29

It should be:

import matplotlib.pyplot as plt
Franco Piccolo
  • 6,845
  • 8
  • 34
  • 52
3

Or it can be:

from matplotlib import pyplot as plt

Also you can read PEP 328 for more information and clearity.

bestor jnr
  • 31
  • 3