In [ ]:
# %pip install chartgpt
from dotenv import load_dotenv
import plotly.io as pio
load_dotenv()
pio.renderers.default = "notebook+plotly_mimetype"
In [ ]:
import pandas as pd
from chartgpt import ChartGPT

df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv")
df.head()
Out[ ]:
Rank State Postal Population
0 1 Alabama AL 4849377.0
1 2 Alaska AK 736732.0
2 3 Arizona AZ 6731484.0
3 4 Arkansas AR 2966369.0
4 5 California CA 38802500.0
In [ ]:
cg = ChartGPT()
cg.load(df)
cg.plot("State vs. Population")
import plotly.express as px

fig = px.bar(df, x='State', y='Population', color='Rank',
             title='State vs. Population',
             hover_data=['Postal'])
fig.show()