1. Write a Python program to create a dataframe containing columns name, age and percentage. Add 10 rows to the dataframe. View the dataframe. 2. Write a Python program to print the shape, number of rows-columns, data types, feature names and the description of the data 3. Write a Python program to view basic statistical details of the data. 4. Write a Python program to Add 5 rows with duplicate values and missing values. Add a column ‘remarks’ with empty values. Display the data 5. Write a Python program to get the number of observations, missing values and duplicate values. 6. Write a Python program to drop ‘remarks’ column from the dataframe. Also drop all null and empty values. Print the modified data.
import pandas as pd
import matplotlib.pyplot as plt
#import seaborn as sns
df=pd.DataFrame(columns=['name','age','percentage'])
df.loc[0]=['lina',19,93]
df.loc[1]=['shruti',18,89]
df.loc[2]=['sakshi',17,90]
df.loc[3]=['pallavi',18,87]
df.loc[4]=['arpita',19,92]
df.loc[5]=['sneha',18,89]
df.loc[6]=['siddhi',20,88]
df.loc[7]=['sejal',20,87]
df.loc[8]=['prachi',19,85]
df.loc[9]=['nikita',20,89]
print(df)
print("Shape of data:",df.shape)
print("No.of rows & columns:",df.size)
print("Data types:",df.dtypes)
print("Features names:",df.info())
print("Description of data:",df.describe())
df.loc[10]=['lina',19,93]
df.loc[11]=['shruti',18,89]
df.loc[12]=['yogita',17,None]
df.loc[13]=['sangeeta',None,87]
df.loc[14]=['ankita',19,92]
df['remark']=None
print(df)
print("Number of obeservation:",df.info())
print("Missing values:",df.isnull())
print("Dupalicate values:",df.duplicated())
df.drop(columns='remark',axis=1,inplace=True)
print(df)
#df.fillna()
#df.dropna()
print(df)
print(df.plot(x='name', y='percentage'))
plt.show()
#print(df.plot.scatter(x="name",y="percentage"))
#plt.show()
Comments
Post a Comment