Skip to content

Commit 30ed873

Browse files
clatapielwasser
authored andcommitted
feat: surfacing other metrics (contributors, stargazers and open issues)
1 parent 76bc75b commit 30ed873

File tree

1 file changed

+120
-15
lines changed

1 file changed

+120
-15
lines changed

contributors/package.qmd

Lines changed: 120 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: pyOpenSci Package Metrics Over Time
2+
title: pyOpenSci Package Metrics
33
jupyter: python3
44
execute:
55
echo: false
66
---
77

8-
This data provides metrics accross all the PyOpenSci packages.
8+
This data provides metrics accross PyOpenSci packages.
99

1010
```{python}
1111
#| echo: false
@@ -38,35 +38,101 @@ package_data_path = Path.cwd().parents[0] / "_data" / "package_data.csv"
3838
3939
# Read the DataFrame from the CSV file
4040
package_df = pd.read_csv(package_data_path)
41-
```
42-
43-
### Forks count per repositories
4441
45-
```{python}
4642
# Parse the "gh_meta" column back into dictionaries
4743
package_df['gh_meta'] = package_df['gh_meta'].apply(
4844
lambda x: ast.literal_eval(x) if isinstance(x, str) else x
4945
)
46+
```
47+
48+
### Forks
5049

50+
```{python}
5151
# Extract "forks_count" value from the 'gh_meta' column
5252
package_df['forks_count'] = package_df['gh_meta'].apply(
53-
lambda x: x.get('forks_count') if isinstance(x, dict) else None
53+
lambda x: x.get('forks_count'
54+
) if isinstance(x, dict) else None
55+
)
56+
```
57+
58+
```{python}
59+
# Render a graph plot of the fork count
60+
chart = (
61+
alt.Chart(package_df).mark_bar(color="#81c0aa")
62+
.encode(
63+
alt.X('package_name', sort='-y')
64+
.title('Package name')
65+
.axis(labelAngle=45),
66+
alt.Y('forks_count:Q')
67+
.title('Fork count'),
68+
)
69+
.properties(title="Number of forks per repository")
70+
.configure_legend(
71+
orient='top',
72+
titleAnchor='middle',
73+
direction='horizontal',
74+
labelFontSize=5,
75+
)
76+
.interactive()
77+
)
78+
79+
chart
80+
```
81+
82+
### Contributors
83+
84+
```{python}
85+
# Extract "contrib_count" value from the 'gh_meta' column
86+
package_df['contrib_count'] = package_df['gh_meta'].apply(
87+
lambda x: x.get('contrib_count') if isinstance(x, dict) else None
88+
)
89+
```
90+
91+
```{python}
92+
# Render a graph plot of contributor count
93+
chart = (
94+
alt.Chart(package_df).mark_bar(color="#f47a78")
95+
.encode(
96+
alt.X('package_name', sort='-y')
97+
.title('Package name')
98+
.axis(labelAngle=45),
99+
alt.Y('contrib_count:Q')
100+
.title('Contributor count'),
101+
)
102+
.properties(title="Number of contributors per repository")
103+
.configure_legend(
104+
orient='top',
105+
titleAnchor='middle',
106+
direction='horizontal',
107+
labelFontSize=5,
108+
)
109+
.interactive()
54110
)
111+
112+
chart
55113
```
56114

115+
### Open issues
116+
117+
```{python}
118+
# Extract "open_issues_count" value from the 'gh_meta' column
119+
package_df['open_issues_count'] = package_df['gh_meta'].apply(
120+
lambda x: x.get('open_issues_count') if isinstance(x, dict) else None
121+
)
122+
```
57123

58124
```{python}
59-
# Render a graph plot of the forks count
125+
# Render a graph plot of open issue count
60126
chart = (
61-
alt.Chart(package_df).mark_bar()
127+
alt.Chart(package_df).mark_bar(color="#735fab")
62128
.encode(
63-
x=alt.X('package_name', sort='-y')
129+
alt.X('package_name', sort='-y')
64130
.title('Package name')
65131
.axis(labelAngle=45),
66-
y=alt.Y('forks_count:Q')
67-
.title('Forks Count'),
132+
alt.Y('open_issues_count:Q')
133+
.title('Open issues count'),
68134
)
69-
.properties(title="Forks Count per Repository")
135+
.properties(title="Number of open issues per repository")
70136
.configure_legend(
71137
orient='top',
72138
titleAnchor='middle',
@@ -79,12 +145,51 @@ chart = (
79145
chart
80146
```
81147

148+
### Stargazers
149+
150+
```{python}
151+
# Extract "stargazers_count" value from the 'gh_meta' column
152+
package_df['stargazers_count'] = package_df['gh_meta'].apply(
153+
lambda x: x.get('stargazers_count') if isinstance(x, dict) else None
154+
)
155+
```
156+
157+
```{python}
158+
# Render a graph plot of stargazer count
159+
chart = (
160+
alt.Chart(package_df).mark_bar(color="#e8cd2a")
161+
.encode(
162+
alt.X('package_name', sort='-y')
163+
.title('Package name')
164+
.axis(labelAngle=45),
165+
alt.Y('stargazers_count:Q')
166+
.title('Stargazer count'),
167+
)
168+
.properties(title="Number of stargazers per repository")
169+
.configure_legend(
170+
orient='top',
171+
titleAnchor='middle',
172+
direction='horizontal',
173+
labelFontSize=5,
174+
)
175+
.interactive()
176+
)
177+
178+
chart
179+
```
180+
181+
182+
### Detailed PyOpenSci metrics
183+
82184
Find bellow the detailed count for each PyOpenSci repository.
83185

84186
```{python}
85187
# Create an itable to display the DataFrame
86188
from itables import show
87189
88190
# Display the results as an interactive table
89-
show(package_df[['package_name', 'forks_count']], max_rows=10)
90-
```
191+
show(
192+
package_df[['package_name', 'forks_count', 'contrib_count', 'open_issues_count', 'stargazers_count']],
193+
max_rows=10
194+
)
195+
```

0 commit comments

Comments
 (0)