3

I have a dataframe which looks like this:

id         date          API_changes    count    content

134     2019-01-01           2           NaN      Nan
134     2019-02-05          34           12       API deleted
134     2019-02-12          18            8       Deprecation
134     2019-03-10          56           29       Segmentation Error
134     2019-05-12          75           40       Path deleted
134     2019-07-01          25           10       Type required
134     2019-10-09          137          55       API deprecated
134     2019-12-31          32           18       Media type removed
134     2020-01-03          150          99       Required param missing

I want to visualize this data in the form of a sunburst, or any chart which can capture the proportion of count in API_changes. count specifies the number of breaking changes out of the API_changes for every commit_date.

I earlier visualized this in the form of a scatter plot with traces(with date on x axis, API_changes on y axis, color as content column, and same for symbol as well), but that does not serve the purpose as I cannot see visually over the dates, how the changes differ in size

One option would be stacked-bar chart, but I was thinking are there more unique charts(preferably a sunburst) for this type of analysis?

1 Answers1

1

You can try and use Plotly Express, which has direct support for Sunburst graph.

Assuming a data.csv with:

id,date,API_changes,count,content
134,2019-01-01,2,,NaN
134,2019-02-05,34,12,API deleted
134,2019-02-12,18,8,Deprecation
134,2019-03-10,56,29,Segmentation Error
134,2019-05-12,75,40,Path deleted
134,2019-07-01,25,10,Type required
134,2019-10-09,137,55,API deprecated
134,2019-12-31,32,18,Media type removed
134,2020-01-03,150,99,Required param missing

You can read the CSV file into a DataFrame:

import pandas as pd

df = pd.read_csv('data.csv')

And create the Sunburst graph:


df['date'] = pd.to_datetime(df['date'])
df['date'] = df['date'].dt.strftime('%Y-%m-%d')

fig = px.sunburst(
    df,
    path=['date', 'content'],
    values='count',
    color='API_changes',
    color_continuous_scale='viridis',
    title='API Changes Sunburst Chart',
    height=600,
)

fig.show()
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250