Page 90 - IPP-12-2024
P. 90
print("Original DataFrame:")
print(df)
csv_file_import = 'data_import.csv'
csv_file_export = 'data_export.csv'
df.to_csv(csv_file_export, index=False)
print("\nData exported to CSV file:", csv_file_export)
imported_df = pd.read_csv(csv_file_export)
print("\nImported DataFrame from CSV:")
print(imported_df)
Output:
Original DataFrame:
name SirName
0 Sachin Bhardwaj
1 Vinod Verma
2 Rajesh Mishra
Data exported to CSV file: data_export.csv
Imported DataFrame from CSV:
name SirName
0 Sachin Bhardwaj
1 Vinod Verma
2 Rajesh Mishra
Program 16. Write a program to plot Bar chart for the given school result data, analyze the
performance of the students on different parameters, e.g. subject wise or class wise.
Solution:
import matplotlib.pyplot as plt
subject=['Physics','Chemistry','Hindi','Biology','ComputerSc']
Percentage=[85,78,65,90,100]
plt.bar(subject,Percentage,align='center',color='green')
plt.xlabel('SUBJECT NAME')
plt.ylabel('PASS PERCENTAGE')
plt.title('Bar Graph For Result Analysis')
plt.show()
Output: