python plotly

PHOTO EMBED

Fri Feb 03 2023 15:51:18 GMT+0000 (Coordinated Universal Time)

Saved by @praveenms079 #python #plotly

import plotly.express as px
import pandas as pd

# Sample DataFrame with three columns: "INSTANCE", "YMD", and "target_count"
df = pd.DataFrame({
    "INSTANCE": ["A", "B", "C", "D", "E"],
    "YMD": ["2021-01-01", "2021-01-02", "2021-01-03", "2021-01-04", "2021-01-05"],
    "target_count": [10, 20, 30, 40, 50]
})
df["YMD"] = pd.to_datetime(df["YMD"])

# Create a new column "weekend" to indicate whether the date is on a weekend
df["weekend"] = df["YMD"].dt.dayofweek >= 5

# Create the bar graph
fig = px.bar(df, x="INSTANCE", y="target_count", color="weekend")

# Show the graph
fig.show()
content_copyCOPY