Code2pdf 679e261343a22
Code2pdf 679e261343a22
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
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
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()