'tooltip' is not working in python leaflet mapping - python

I am using python 3.6 Following is my simple code:
import folium
city_location = [-23.6573395, -46.5322504]
m = folium.Map(location=city_location, zoom_start=15, tiles='openstreetmap')
folium.Marker(city_location, popup='<i>Teste</i>', tooltip='Click me!').add_to(m)
m
But I keep getting the error saying:
TypeError: __init__() got an unexpected keyword argument 'tooltip'
What can I do to show a tooltip upon my marker ?

The tooltip was added with the version v.0.0.6.
Refer to this issue : https://github.com/python-visualization/folium/pull/724
From your comment, it was six month after you installed it.
So, update your dependencies and it should work
You can check your version by doing pip freeze > requirements.txt
Check the folium version there. If it is under 0.0.6, then perform a :
pip install folium --upgrade and you are done
Also, check the Release page, this library is in active development, so you should always update if you want to enjoy and test the last features !

Related

dataclass_transform() got an unexpected keyword argument 'field_specifiers'

I am trying to work with this G2P package. But I am getting dataclass_transform() got an unexpected keyword argument 'field_specifiers' this error. I am trying to run their sample code that they have provided there after running !pip install g2p_en in my jupyter notebook. The sample code for which I am getting the error is attached below. Can someone please help me with the issue?
from g2p_en import G2p
texts = ["I have $250 in my pocket.", # number -> spell-out
"popular pets, e.g. cats and dogs", # e.g. -> for example
"I refuse to collect the refuse around here.", # homograph
"I'm an activationist."] # newly coined word
g2p = G2p()
for text in texts:
out = g2p(text)
print(out)
Install the package from the anaconda base location (assuming you are using anaconda for jupyter notebook) with this command
conda install -c conda-forge g2p-en
Then simply import from g2p_en import G2p and run the example code. For me it did the job. There are various dependencies on anaconda base level which are not fully satisfied when you install the package from the jupyter lab only. You need to install from anaconda base location sometimes to make it work.

Error exporting styled dataframes to image, "SyntaxError: not a PNG file" using dataframe_image

I've been using dataframe_image for a while and have had great results so far. Last week, out of a sudden, all my code containing the method dfi.export() stopped working with this error as an output
raise SyntaxError("not a PNG file")
File <string>
SyntaxError: not a PNG file
I can export the images passing the argument table_conversion='matplotlib' but they do not come out styled...
This is my code:
now = str(datetime.now())
filename = ("Extracciones-"+now[0:10]+".png")
df_styled = DATAFINAL.reset_index(drop=True).style.apply(highlight_rows, axis=1)
dfi.export(df_styled, filename,max_rows=-1)
IMAGEN = Image.open(filename)
IMAGEN.show()
Any clues on why this just suddenly stopped working?
Or any ideas to export dataframes as images (not using html)?
These were the outputs i used to get:
fully styled dataframe images
and this is the only thing I can get right now
Thank you in advance
dataframe_image has a dependency on Chrome, and a recent Chrome update (possibly v109 on 2013-01-10) broke dataframe_image. v0.1.5 was released on 2023-01-14 to fix this.
pip install --upgrade dataframe_image
pip show dataframe_image
The version should now be v0.1.5 or later, which should resolve the problem.
Some users have reported still having the error even after upgrading. This could be due to upgrading the package in the wrong directory (due to multiple installations of python, pip, virtual envs, etc). The reliable way to check the actual version of dataframe_image that the code is using, is to add this debugging code to the top of your python code:
import pandas as pd
import dataframe_image as dfi
from importlib.metadata import version
print(version('dataframe_image'))
df = pd.DataFrame({'x':[1,2]})
dfi.export(df, 'out.png')
exit()
Also check chrome://version/ in your Chrome browser.
I had the same issue, and we finally figured it out; looks like the new release of dataframe_image on 1/14 broke something on the previous version.
We upgraded the package and the issue was resolved.
pip install -u dataframe_image
I fixed this issue.
It was related to resources that are busy in the background and chrome can't use these resources.
https://github.com/dexplo/dataframe_image/pull/70
please update the library to version v0.1.5
you can do it via pip :
python -m pip install --upgrade dataframe-image
Good luck.

Crs setting in scikit mobility. Python

I am trying to use scikit mobility to recreate trajectories and stop location from GPS https://scikit-mobility.github.io/scikit-mobility/reference/data_structures.html#module-skmob.core.trajectorydataframe
By using TrajDataFrame and then I am applying
stdf = detection.stay_locations(tdf, stop_radius_factor=0.5, minutes_for_a_stop=20.0, spatial_radius_km=0.2, leaving_time=True)
my data looks the same as in example but I am getting the error ''TrajDataFrame' object has no attribute '_crs''. CRS is just optional and even when I added the error is appearing. Does anyone had the same issue?
This problem has been solved in the current version (v1.3.1), which works for versions of python >= 3.8.
If you are using it in Google Colab (for which version 3.8 is not available yet), after having installed scikit-mobility, you need to downgrade the pandas library to version 1.2.5:
!pip install pandas==1.2.5
Then, the problem should be solved. See also this solved issue: https://github.com/scikit-mobility/scikit-mobility/issues/204

New variable in plt.streamplot() broken_streamlines does not work, how to fix this?

I need my streamlines on the plot in Python to be continuous. I am using plt.streamplot() which by default plots broken lines. I have found that in the source code someone has already made up a variable which is called broken_streamlines and it can be True or False, by default it is True broken_streamlines.
In documentation of matplotlib.pyplot.streamplot it does not exist, but in documentation of matplotlib.axes.Axes.streamplot it does exist.
Unfortunatelly it does not work neither in plt.streamplot() nor Axes.streamplot() and I got communicate:
TypeError: streamplot() got an unexpected keyword argument 'broken_streamlines'
What can I do about this? I have been looking for other solution to force the lines to be continuous (eg. density, start points, minlenght etc.) but it occurs that my data is very difficult to manipulate. What possibly can I do wrong (Python3 is already actualized)? I already tried it on MacOS and Linux.
Upgrade your version of the matplotlib package by running pip install matplotlib --upgrade
The broken_streamlines parameter was introduced in Matplotlib 3.6.0 - see the relevant changelog entry below:
https://matplotlib.org/stable/users/prev_whats_new/whats_new_3.6.0.html#streamplot-can-disable-streamline-breaks
Also see the changes in the documentation of the streamplot function:
version 3.5.3 https://matplotlib.org/3.5.3/api/_as_gen/matplotlib.pyplot.streamplot.html
version 3.6.0 https://matplotlib.org/3.6.0/api/_as_gen/matplotlib.pyplot.streamplot.html

Unable to import todoist.api

Trying to access the todoist api, and I copied some code from the api documentation. However, on my system I get an error stating:
Unable to import 'todoist.api'pylint(import-error).
I installed it with:
pip install todoist-python
as mentioned in the documentation
from todoist.api import TodoistAPI
I get my error on the very first line. How do I not get this?
You did everything right, so it's probably related to the way your installation is set.
Be sure you are using the same python you used to install the library. Check if the library is installed (pip list) and check if you're using the right Python when running the code. It's possible that the library was installed in one version and you're using the other.
I had the same problem, I solved it by following the GitHub instructions, but the name of the module to install using pip is todoist.

Categories

Resources