Top 10 Pandas Functions
- Naveen
- 0
1 – To Read CSV and Excel files.
These Functions will be used in almost every Project, They are used to read a CSV or an excel file to pandas DataFrame format.
2 – Columns Function.
When we have a big dataset with many columns it will be difficult to see all columns, hence we can use df.columns to print all columns
3 – Head and Tail Function.
- df.head() returns first n rows, if no input is given it returns 5 rows.
- df.tail() returns the last n rows, if no input is given it returns 5 rows.
- df.sample() returns the random values if input is given.
4 – length and Shape Functions.
- len(df) function provides the length of the DataFrame
- df.shape function returns no of rows and columns in a data frame.
5 – Describe Function
To understand the basic statistics of variables we can use df.describe().
6 – Nunique Function
To get the total unique values of variables, we can use df.nunique().
7 – iloc() Function
This function takes as a parameter the rows and columns indices and gives you the subset of the DataFrame accordingly.
8 – loc() Function
This function does almost the similar operation as iloc() function. But here we can specify exactly which row index we want and also the name of the columns we want in our subset.
9 – dtypes Function
We use this function to find the data type of a column.
10 – Replacing Null values
This function .fillna() replaces the null values with some other value of your choice.