filmov
tv
61. DataFrame Modification Pandas || filter(), rename(), join(), groupby(), sort(), to_dict() Coding
Показать описание
Code:
import pandas as pd
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19],'Marks':[76,85,91.7]}
student_df=pd.DataFrame(student_dict)
filter=student_df['Marks'](less_than_sign)80
student_df['Marks'].where(filter,other=0,inplace=True)
print(student_df)
print(student_df)
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19],'Marks':[76,85,91.7]}
student_df=pd.DataFrame(student_dict)
print(student_df)
#join
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19]}
student_df=pd.DataFrame(student_dict)
marks_dict={'Marks':[77,92,85]}
marks_df=pd.DataFrame(marks_dict)
print(marks_dict)
print(joined_df)
#group by
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Class':['C','A','B'],'Marks':[76,85,91.7]}
student_df=pd.DataFrame(student_dict)
print(student_df)
#DFIteration
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19],'Marks':[76,85,91.7]}
student_df=pd.DataFrame(student_dict)
print(index,row)
#Sort
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19],'Marks':[86,85,71.7]}
student_df=pd.DataFrame(student_dict)
print(student_df)
print(dict)
Watch more videos on @sevent
import pandas as pd
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19],'Marks':[76,85,91.7]}
student_df=pd.DataFrame(student_dict)
filter=student_df['Marks'](less_than_sign)80
student_df['Marks'].where(filter,other=0,inplace=True)
print(student_df)
print(student_df)
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19],'Marks':[76,85,91.7]}
student_df=pd.DataFrame(student_dict)
print(student_df)
#join
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19]}
student_df=pd.DataFrame(student_dict)
marks_dict={'Marks':[77,92,85]}
marks_df=pd.DataFrame(marks_dict)
print(marks_dict)
print(joined_df)
#group by
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Class':['C','A','B'],'Marks':[76,85,91.7]}
student_df=pd.DataFrame(student_dict)
print(student_df)
#DFIteration
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19],'Marks':[76,85,91.7]}
student_df=pd.DataFrame(student_dict)
print(index,row)
#Sort
student_dict={'Name':['Saubari','Kandu','Vritasur'],'Age':[22,24,19],'Marks':[86,85,71.7]}
student_df=pd.DataFrame(student_dict)
print(student_df)
print(dict)
Watch more videos on @sevent