Attribute Error: folium has no attribute map - python

The error I am getting is like below:
Traceback (most recent call last)
<ipython-input-37-637818dcbe0d> in <module>
----> 1 mp = folium.map(location=[151.1780,33.7961], zoom_start=10)
2
3 choropleth = folium.Choropleth(
4 geo_data=suburbs,
5 data=rentwpostcode,
AttributeError: module 'folium' has no attribute 'map'
I tried installing folium through both conda and git clone. Both times the error remained. I also tried to removing folium.py but still it didn't work.

The error you're seeing is not related to the installation of folium. Names in Python are case-sensitive so .map() is not the same as .Map(). Change your code to mp = folium.Map(location=[151.1780,33.7961], zoom_start=10) and it'll work fine.

Related

Is there a substitute for matplotlib.pyplot.colors?

I am trying the function on this doc
import matplotlib.pyplot as plt
plt.colors()
got this error
--------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-1-e2c1adbcc48e> in <module>
1 import matplotlib.pyplot as plt
----> 2 plt.colors()
AttributeError: module 'matplotlib.pyplot' has no attribute 'colors'
the doc says
The colors function was deprecated in version 2.1.
without providing a substitute.
is there a substitute for matplotlib.pyplot.colors?
To be more precise here: No, there is no substitude for matplotlib.pyplot.colors because its only purpose was to allow users to get help via help(plt.colors). It was considered more harmful to confuse users by the presence of this function, which doesn't do anything, than it to be useful to let them get help on colors via pyplot. If you want to get help on colors now, you may still type
help(matplotlib.colors)
though that is a bit more lengthy.

'function' object has no attribute 'plot'

I was following this tutorial https://www.kaggle.com/residentmario/univariate-plotting-with-pandas
and trying to do the exercise mentioned with the pokemon database but whenever I try to implement the code below I get the error mentioned below and don't understand what to do. I am using matplotlib.use('agg') because I was getting an error related to Tkinter. I am using pycharm, python 3.6 and I am on ubuntu 18.04
Here is my code:
import pandas as pd
import matplotlib
matplotlib.use('agg')
from matplotlib.pyplot import plot
df=pd.read_csv("/home/mv/PycharmProjects/visualization/pokemon.csv")
df['type1'].value_counts.plot(kind='bar')
error
Traceback (most recent call last):
File "/home/mv/PycharmProjects/visualization/univariate plotting.py",
line 9, in <module>
df['type1'].value_counts.plot(kind='bar')
AttributeError: 'function' object has no attribute 'plot'
The error states that df['type1'].value_counts is a function.
To plot the result of the function change:
df['type1'].value_counts.plot(kind='bar')
into
df['type1'].value_counts().plot(kind='bar')

2 monitors, pygame.display.Info won't work

I have two monitors (one is 1920x1080, the other is 1024x768) and I've just started a new game and ran into an issue with pg.display.Info:
import pygame as pg
pg.init()
x,y = pg.display.Info()
It gives me the following error:
Traceback (most recent call last):
File "C:\Users\marty\Desktop\New Text Document (2).py", line 3, in
x,y = pg.display.Info()
TypeError: 'VidInfo' object is not iterable
Even after isolating the code to those three lines, the same error gets raised. I couldn't find any info on 2 monitors in Python.
PS: pygame is updated, according to pip. My Python version is 3.6.5, and I'm running windows 10.
You can't unpack the VidInfo object which pg.display.Info() returns like that. Assign it to a single variable and then use the attributes that you need. For example:
info = pg.display.Info()
print(info)
print(info.current_w, info.current_h)

Resolving "AttributeError: module 'dask.bag' has no attribute 'from_filenames'"

I am following a simple tutorial to load Reddit comment data from pushshift.io into a dask bag. I am getting the strange error: "Resolving "AttributeError: module 'dask.bag' has no attribute 'from_filenames'", despite the fact that this is standard procedure as described here: http://dask.pydata.org/en/doc-test-build/bag.html
import dask
import dask.bag as db
data = db.from_filenames("reddit_1_28_2018.txt", chunkbytes=100000).map(json.loads)
AttributeError Traceback (most recent call last)
<ipython-input-17-bcbd31affbfb> in <module>()
2 import dask.bag as db
3
----> 4 data = db.from_filenames("reddit_1_28_2018.txt", chunkbytes=100000).map(json.loads)
AttributeError: module 'dask.bag' has no attribute 'from_filenames'
I suspect that the resource you were looking at was very old. I recommend reading the Dask documentation for up-to-date information.
I suspect that you're looking for db.read_text

Why would Plotly not recognise attribute 'offline'?

I'm following the tutorial plotly timeseries, here. I've also amended the code to allow for offline charts in Jupyter, here.
I'm trying to plot a timeseries in Jupyter Notebook. I get the following error.
AttributeError: module 'plotly.plotly' has no attribute 'offline'
As far as I can see I've carried out all the instructions but can't get it to work with the method they suggest.
import plotly.plotly as py
import plotly.graph_objs as go
py.offline.init_notebook_mode()
data = [go.Scatter(x=dataload.date, y=dataload.spend)]
py.offline.iplot(data)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-14-c9b2e8d8907c> in <module>()
2 import plotly.graph_objs as go
3
----> 4 py.offline.init_notebook_mode()
5
6 data = [go.Scatter(x=dataload.date, y=dataload.spend)]
AttributeError: module 'plotly.plotly' has no attribute 'offline'
Does anyone have a suggestion to why I might be getting this error, could it be a local setup issue?
Just use:
import plotly
plotly.offline.init_notebook_mode()
don't use: import plotly.plotly as py
You are referring different documentation. Use https://plot.ly/python/getting-started/#initialization-for-offline-plotting
Here it also provides more information regarding how to use help function.
For tutorial in offline mode: https://github.com/SayaliSonawane/Plotly_Offline_Python

Categories