-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.py
More file actions
28 lines (21 loc) · 771 Bytes
/
report.py
File metadata and controls
28 lines (21 loc) · 771 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import pandas as pd
import matplotlib.pyplot as plt
import json
# Load the data from the JSON file
with open('data_source.json') as f:
data = json.load(f)
# Convert the JSON data to a pandas DataFrame
df = pd.DataFrame(data)
# Count the frequency of each country
country_counts = df['country'].value_counts()
# Create a pie chart
plt.pie(country_counts, labels=country_counts.index, autopct='%1.1f%%')
plt.title('Most Popular Countries')
plt.show()
# Analysis
print("Analysis:")
print("The most popular countries on your website are:")
print(country_counts.head())
print("\nTo improve your website, you might want to consider adding more content or features that cater to these countries.")
# Export the data to a CSV file
df.to_csv('output.csv', index=False)