FUNCTIONS USED IN DATAFRAME
Creating dataframe for our project:
import pandas as pd
import numpy as np
data={“Name”:[“Sumit”,”Aditya”,”Pravesh”,”Sandeep”,”Kuldeep”,”Vivek”,”Palak”,”Neha”,”Shivam”,”Anjali”,”Ritu”],
“Sports”:[“Football”,”Circket”,”Circket”,”Athletics”,”Chess”,”Football”,”Batminton”,”Batminton”,”Cirket”,”Kho-Kho”,”Athletics”],
“Subject”:[“IP”,”IP”,”IP”,”HINDI”,”IP”,”MATHS”,”IP”,”IP”,”HINDI”,”HINDI”,”HINDI”],
“class 10 result(%)”:[70,65,72,71,64,68,91,73,65,66,65]
}
Dataframe1=pd.DataFrame(data=data,index=range(1,12))
print(dataf
DFO = DataFrame Object
S.no | FUNCTION | USE | EXAMPLE |
1. | <DFO >.loc[<start row>:<end row>, <start column>: <end column>]] | To access a subset from a DataFrame using Row/Colum names. | dataframe.loc[1:5,”Name”:”Sports”] |
2. | <DFO>.iloc[<start row index>:<end row index>, <start col index>:<end col index>] | To obtain a slice from a DataFrame using row/column numeric index/position. | dataframe.iloc[0:6,0:2] |
3. | <DFO>.at[<row name>,<column name>] | To access a single value for a row/column name pair. | dataframe.at[5,”class 10 result(%)”] |
4. | <DFO>.iat[<row index no>,<col index number>] | To access single value for a row/column pair by integer position. | dataframe.iat[5,3] |
5. | <DFO>.drop(index or sequence of index) | To delete row from a dataframe. | dataframe.drop(5) |
6. | <DFO>.iterrows() | TO process all the data values of a dataframe. It use row . | for (row,rowseries) in dataframe.iterrows(): print(“row index:\t\n”,row) print(“contaning\n\n”,rowseries) |
7. | <DFO>.iteritems() | To process all the data values of a dataframe using colums in once. | for (itemno,itemdata) in dataframe.iteritems(): print(“column index:\t\n”,itemno) print(“contaning\n\n”,itemdata) |
8. | <DFO>.add(<DFO1>) | To add data of two dataframes. radd() for adding revese. You can use + also | dataframe.add(dtf1) |
9. | <DFO>.sub(<DFO1>) | To subtract data of two dataframes. rsub() for subtracting reverse. You can also use -. | dataframe.sub(dtf1) |
10. | <DFO>.mul(<DFO1>) | To multiply the data of two dataframes. You can also use *. | dataframe.mul(dtf1) |
11. | <DFO>.div(<DFO1>) | To divide data of two dataframes. You can also use /. | dataframe.div(dtf1) |
12. | <DFO>.info() | It give you basic information about your datafarme object. It give you detail about : 1.type. 2.index values. 3.number of rows. 4.data columns and values in them. 5. Datatype of each colums. 6.memory usage. | dataframe.info() |
13. | <DFO>.describe() | It also give detail of data but about: 1.counting of NaN values in a column 2.Mean 3.standard deviation 4.percentile 5.minmum value 6. maximum value All detail about column. | dataframe.describe() |
14. | <DFO>.cumsum([axis=noun]) | To cumulative sum of row or colums . | For rows: dataframe.cumsum(axis=”rows”) For columns: dataframe.cumsum(axis=”columns”) |
15. | <DFO>.dropna() | To remove missing values from the data. | dataframe.dropna() |
16. | <DFO>.fillna() | To fill the missing values. | dataframe.fillna() |
17. | <DFO>.empty | It return the Boolean value if dataframe is empty than true otherwise false | dataframe.empyt |
18. | <DFO>.any() | This function returns true if any element is true. | dataframe.any() |
19. | <DFO>.all() | This function returns true If all values are true. | dataframe.all() |
20. | <DFO>.combine_first(<DFO1>) | This function combines the two dataframe. | dataframe.combine_first(dtf1) |
21. | pandas.concat([<DF1>,<DF2>]) | This function also combine the two dataframes. | Newdf=pd.concat([dataframe,df1]) |