0% found this document useful (0 votes)
3 views2 pages

Code2pdf 679e261343a22

The document is a Python script for an Instagram Analytics System that allows users to view, add, and analyze post data including likes, comments, engagement rate, and views. It utilizes pandas for data manipulation and matplotlib for data visualization. The script includes a menu-driven interface for user interaction and handles the creation of a CSV file to store the data if it does not already exist.

Uploaded by

prince18aarya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Code2pdf 679e261343a22

The document is a Python script for an Instagram Analytics System that allows users to view, add, and analyze post data including likes, comments, engagement rate, and views. It utilizes pandas for data manipulation and matplotlib for data visualization. The script includes a menu-driven interface for user interaction and handles the creation of a CSV file to store the data if it does not already exist.

Uploaded by

prince18aarya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

import pandas as pd

import matplotlib.pyplot as plt


import os
FILE='instagram_analysis.csv'
if not os.path.exists(FILE):
df = pd.DataFrame(columns=["Post", "Likes", "Comments","engagement_rate","views"])
df.to_csv(FILE, index=False)
def menu():
while True:
print("\n Instagram Analytics System")
print("1️⃣ View Data")
print("2️⃣ Add New Post Data")
print("3️⃣ Show Data Analysis")
print("4️⃣ ENGAGEMENT RATE")
print("5 exit")

choice = input("Enter your choice (1-5): ")

if choice == "1":
View_data()
elif choice == "2":
add_data()
elif choice == "3":
analyze_data()
elif choice == "4":
ENGAGEMENT_RATE()
elif choice == "5":
print(" Exiting... Bye! ")
break
else:
print("❌ Invalid Choice! Try Again.")

def View_data():
df = pd.read_csv(FILE)
if df.empty:
print(" No data available!")
else:
print("\n Instagram Data:")
print(df)

def add_data():
post = input("Enter Post Name: ")
likes = int(input("Enter Number of Likes: "))
comments = int(input("Enter Number of Comments: "))
engagement_rate=int(input('enter number of rate: '))
views = int(input('enter no. of views: '))
df = pd.read_csv(FILE)
new_data = pd.DataFrame([[post, likes, comments]], columns=["Post", "Likes", "Comments","engagement_rate","views"])
df = pd.concat([df, new_data], ignore_index=True)
df.to_csv(FILENAME, index=False)
print("✅ Data Added Successfully!")

def analyze_data():
df = pd.read_csv(FILE)
if df.empty:
print(" No data available for analysis!")
return

print("\n Data Insights:")


print(df.describe())

plt.figure(figsize=(8, 5))
plt.bar(df["Post"], df["Likes"], color='blue', label="Likes")
plt.bar(df["Post"], df["Comments"], color='red', label="Comments")
plt.xlabel("Posts")
plt.ylabel("Count")
plt.title("Likes vs Comments Analysis")
plt.legend()
plt.xticks(rotation=45)
plt.show()

def ENGAGEMENT_RATE():
df = pd.read_csv(FILE)
if df.empty:
print(" No data available for analysis!")
return

print("\n Data Insights:")


print(df.describe())

plt.figure(figsize=(8, 5))
plt.plot(df["engagement_rate"], df["Views"], color='red', label="Views vs Engagement Rate")
plt.xlabel("Engagement Rate")
plt.ylabel("Views")
plt.legend()
plt.show()

menu()

You might also like