12 IP File Programs 6 To 17
12 IP File Programs 6 To 17
df = pd.DataFrame(exam_data , index=labels)
print("Number of student whoes percentage more than 70:")
print(df[df['perc'].between(70,90)])
df = pd.DataFrame(exam_dic , index=labels)
print("\nOriginal data frame:")
print(df)
ch = input("Enter the index of row : ")
per = float(input("Enter percentage to be changed: "))
print('\nChange the percentage in row '+ch+ ' to',per)
df.loc[ch, 'perc'] = per
print(df)
# 8 Write a Pandas program to select the rows where the percentage greater
than 70.
import pandas as pd
import numpy as np
df = pd.DataFrame(exam_data , index=labels)
print("Number of student whoes percentage more than 70:")
print(df[df['perc'] > 70])
#9 Write a Pandas program to join the two given dataframes along rows and
assign all data.
import pandas as pd
import numpy as np
exam_data1 = pd.DataFrame(exam_dic1)
exam_data2 = pd.DataFrame(exam_dic2)
print("Original DataFrames:")
print(exam_data1)
print("-------------------------------------")
print(exam_data2)
print("\nJoin the said two dataframes along rows:")
result_data = pd.concat([exam_data1, exam_data2])
print(result_data)
print("Original DataFrames:")
print(exam_data1)
print("\nDictionary:")
print(s)
# Add Series
combined_data = exam_data1.append(s, ignore_index=True, sort=False)
# Add Dictionary
combined_info = combined_data.append(dicts, ignore_index=True,
sort=False)
print("\nCombined Data:")
# Print Combined Data/info
print(combined_info)
exam_data1 = pd.DataFrame(exam_dic1)
print("Original DataFrames:")
print(exam_data1)
print("\nUse == operator\n")
print(exam_data1.loc[exam_data1['name'] == 'Rohan'])
#12 Importing and exporting data between pandas and CSV file.
import pandas as pd
import csv
#Reading the Data
df = pd.read_csv("student_result.csv")
# Display Name of Columns
print(df.columns)
# Display no of rows and column
print(df.shape)
# Display Column Names and their types
print(df.info())
import pandas as pd
import numpy as np
import csv
# find the highest percentage and also print the student’s name and
percentage.
df1 = pd.read_csv("student_result.csv")
df1 = df1[["STUDENT'S_NAME",'PERCENTAGE']][
df1.PERCENTAGE== df1['PERCENTAGE'].max()]
print(df1)
#16 Given the school result data, analyses the performance of the students
on different parameters, e.g subject wise or class wise.
# x-axis is shows the subject and y -axis
# shows the markers in each subject
import matplotlib.pyplot as pl
**************