Osama Billah
Osama Billah

Reputation: 93

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

Upvotes: 7

Views: 38530

Answers (2)

bestor jnr
bestor jnr

Reputation: 31

Or it can be:

from matplotlib import pyplot as plt

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

Upvotes: 3

Franco Piccolo
Franco Piccolo

Reputation: 7430

It should be:

import matplotlib.pyplot as plt

Upvotes: 34

Related Questions