Skip to content

Instantly share code, notes, and snippets.

@neelindresh
Created February 20, 2019 19:06
Show Gist options
  • Save neelindresh/ede6b6a094d1b7ea771f519c431ad598 to your computer and use it in GitHub Desktop.
Save neelindresh/ede6b6a094d1b7ea771f519c431ad598 to your computer and use it in GitHub Desktop.
import plotly.offline as py
import pandas as pd
df = pd.read_csv('tweet_location.csv')
count_dict=dict(df['Country'].value_counts())
df['count']=df['Country'].map(count_dict)
df=df.drop(['Unnamed: 0'],axis=1)
df=df.drop_duplicates()
print(df)
data = [ dict(
type = 'choropleth',showscale=False,autocolorscale=False,locations=df['Country'],text = df['Country'],z=df['count'],locationmode='country names')]
py.plot(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment