Program to add two series

In this python pandas program, we will add two series using pandas.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create two series using pd.Series().
  3. Now add the two series using the” + ” operator.
  4. Print the output.
				
					import pandas as pd
df1 = pd.Series([1,6,9,5])
df2 = pd.Series([5,2,4,5])
print(df1+df2)
				
			

Output :

				
					0     6
1     8
2    13
3    10
dtype: int64
				
			

convert a series to a list and print its type

subtract two series

Convert a Pandas series to a list and print its type

In this python pandas program, we will convert a Pandas series to a list and print its type.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create a pandas series using pd.Series() and print it.
  3. Now, convert the series to a list using tolist().
  4. To print the type use type().
				
					import pandas as pd
df = pd.Series([15,43,88,23])
print(df)
print(type(df))
print("Convert Pandas Series to Python list")
print(df.tolist())
print(type(df.tolist()))
				
			

Output :

				
					0    15
1    43
2    88
3    23
dtype: int64
<class 'pandas.core.series.Series'>
Convert Pandas Series to Python list
[15, 43, 88, 23]
<class 'list'>
				
			

create and display a one-dimensional array-like object containing an array of data

add two series

Python Pandas Programs, Exercises

Python Pandas Programs helps to filter and sort the tabular data and gain expertise on it, Pandas is an open-source library for data analysis in Python. Pandas is one of the most popular and fastest-growing libraries in the Python ecosystem.

1). Python Pandas program to create and display a one-dimensional array-like object containing an array of data.
Output:
15
43
88
23

2). Python Pandas program to convert a series to a list and print its type.

3). Python Pandas program to add two series.
Input:
A=[1,6,9,5]
B=[5,2,4,5]
Output:
[6,8,13,10]

4). Python Pandas program to subtract two series.
Input:
A=[1,6,9,5]
B=[5,2,4,5]
Output:
[-4,4,5,0]

5). Python Pandas program to multiply two series.
Input:
A=[1,6,9,5]
B=[5,2,4,5]
Output:
[5,12,36,25]

6). Python Pandas program to divide two series.
Input:
A=[1,6,9,5]
B=[5,2,4,5]
Output:
[0.2,3,2.5,1]

7). Python Pandas program to check whether elements in the series are equal or not.
Input:
A=[1,6,9,5]
B=[5,2,4,5]
Output:
False
False
False
True

8). Python Pandas program to check whether elements in the series are greater than other series.
Input:
A=[1,6,9,5]
B=[5,2,4,5]
Output:
False
True
True
False

9). Python Pandas program to convert a dictionary to a series.
Input:
A={name: Virat, sport: cricket, age: 32}
Output:
Name Virat
Sport Cricket
Age 32

10). Python Pandas program to convert a NumPy array to a Pandas series.
Input:
[5,3,8,9,0]
Output:
0 5
1 3
2 8
3 9
4 0

11). Python Pandas program to change the data type of given a column or a Series.
Input:
0 54
1 27.90
2 sqa
3 33.33
4 tools
dtype: object
Output:
0 54.00
1 27.90
2 NaN
3 33.33
4 NaN
dtype:float64

12). Python Pandas program to convert a given Series to an array.
Input:
0 54
1 27.90
2 sqa
3 33.33
4 tools
dtype: object
Output:
[’54’, ‘27.90’,’sqa’,’33.33′, ‘tools’]

13). Python Pandas program to convert a series of lists into one series.
Input:
[Sqa, tool]
[Learning, python]
[Is, fun]
Output:
0 [Sqa, tool]
1 [Learning, python]
2 [Is, fun]
dtype: object

14). Python Pandas program to sort a given Series.
Input:
0 55
1 23
2 10
3 87
Output:
0 10
1 23
2 55
3 87

15). Python Pandas program to add some data to an existing series.
Input:
0 54
1 27.90
2 sqa
3 33.33
4 tools
Output:
0 54
1 27.90
2 sqa
3 33.33
4 tools
5 python
6 100

16). Python Pandas program to create a subset of a given series based on value and condition.
Input:
0 10
1 25
2 69
3 74
4 33
5 54
6 21
Output:
Subset of the above Data Series:
0 10
1 25
4 33
6 21

17). Python Pandas program to change the order of the index of a given series.
Input:
0 Sqa
1 tools
2 Learning
3 python
4 Is
5 fun
Output:
2 Learning
3 python
0 Sqa
1 tools
4 Is
5 fun

18). Python Pandas program to find the mean of the data of a given series.
Input:
0 5
1 4
2 8
3 6
Output:
5.75

19). Python Pandas program to find the standard deviation of the  given Series.
Input:
0 2
1 4
2 6
3 8
4 10
Output: = 3.162277

20). Python Pandas program to get the items of a series not present in another series.
Input:
A=
0 4
1 7
2 3
B=
0 9
1 4
2 3
Output:
Items of A that are not present in B
1 7

21). Python Pandas program to calculate the maximum value from a series.
Input:
0 54
1 38
2 67
3 87
Output:
87

22). Python Pandas program to calculate the minimum value from a series.
Input:
0 54
1 38
2 67
3 87
Output:
38

23). Python Pandas program to calculate the frequency of each value of a series.
Input:
0 3
1 0
2 3
3 2
4 2
5 0
6 3
7 3
8 2
Output:
0 2
2 3
3 4

24). Python Pandas program to extract items at given positions of a series.
Input:
0 3
1 0
2 3
3 2
4 2
5 0
6 3
7 3
8 2
Output:
1 0
4 2
7 3

25). Python Pandas program to convert the first and last character of each word to upper case in each word of a given series.
Input:
0 sqatools
1 python
2 data
3 science
Output:
0 SqatoolS
1 PythoN
2 DatA
3 SciencE

26). Python Pandas program to calculate the number of characters in each word in a series.
Input:
0 Virat
1 Rohit
2 Pant
3 Shikhar
Output:
0 6
1 6
2 4
3 7

27). Python Pandas program to convert a series of date strings to a time-series.
Input:
0 2 Feb 2020
1 5/11/2021
2 7-8-2022
Output:
0 2020-02-02 00:00:00
1 2021-11-05 00:00:00
2 2022-08-07 00:00:00

28). Python Pandas program to filter words from a given series that contain at least one vowel.
Input:
0 sqatools
1 SQL
2 python
3 white
4 bsc
Output:
0 sqatools
2 python
3 white

29). Python Pandas program to find the index of the first occurrence of the smallest and largest value of a series.
Input:
0 54
1 25
2 38
3 87
Output:
1
3

30). Python Pandas program to convert a dictionary into DataFrame.

31). Python Pandas program to print the first n rows of a Dataframe.

32). Python Pandas program to print the last n rows of a DataFrame.

33). Python pandas program to print the selected columns from DataFrame.
Input:
Sr.no. name age
1        Alex    30
2        John   27
3        Peter   29
Output:
name age
Alex     30
John    27
Peter   29

34). Python Pandas program to print the selected rows from DataFrame.
Input:
Sr.no. name age
1.        Alex   30
2.        John  27
3.        Peter 29
Output:
Sr.no. name age
2.       John   27

35). Python Pandas program to select the rows where the age is greater than 29.
Input:
Sr.no. name   age
1.       Alex.     30
2.       John.    27
3.       Peter.   29
4.       Klaus.   33
Output:
Sr.no. name age
1. Alex. 30
4. Klaus. 33

36). Python Pandas program to count the number of rows and columns in a DataFrame.
Input:
Sr.no. name   age
1.        Alex.   30
2.        John.   27
3.        Peter.  29
4.        Klaus.  33
Output:
No of rows:4
No of columns:3

37). Python Pandas program to select the rows where age is missing.
Input:
Sr.no. name  age
1.       Alex.   30
2.      John.   np.nan
3.      Peter.  29
4.      Klaus.  np.nan
Output:
Sr.no. name age
2.       John.  np.nan
4.       Klaus. np.nan

38). Python Pandas program to print the names who’s age is between 25-30 using Pandas.
Input:
Sr.no. name  age
1.       Alex.    30
2.       John.   27
3.       Peter.  29
4.       Klaus.  33
Output:
Sr.no. name  age
2.       John.   27
3.       Peter.  29

39). Python Pandas program to change the age of John to 24.
Input:
Sr.no. name  age
1.       Alex.    30
2.       John.   27
3.       Peter.  29
4.       Klaus.  33
Output:
Sr.no. name  age
1.       Alex.    30
2.       John.   24
3.       Peter.  29
4.       Klaus.  33

40). Python Pandas program to calculate the sum of age column.
Input:
Sr.no. name  age
1.       Alex.   30
2.      John.   27
3.      Peter.  29
4.      Klaus.  33
Output:
119

41). Python Pandas program to add a new row in the DataFrame.
Input:
Sr.no. name  age
1.       Alex.   30
2.      John.   27
3.      Peter.  29
4.      Klaus.  33
Output:
Sr.no. name  age
1.       Alex.    30
2.       John.   27
3.       Peter.  29
4.       Klaus.  33
5.      Jason.  28

42). Python Pandas program to sort the DataFrame first by ‘name’ in ascending order.
Input:
Sr.no. name  age
1.       Alex.    30
2.       John.   27
3.       Peter.  29
4.       Klaus.  33
Output:
Sr.no. name   age
1.       Alex.     30
2.       John.    27
4.       Klaus.   33
3.       Peter.   29

43). Python Pandas program to calculate the mean of age column.
Input:
Sr.no. name   age
1.       Alex.     30
2.       John.    27
3.       Peter.   29
4.       Klaus.   33
Output:
29.75

44). Python Pandas program to sort the DataFrame by ‘age’ column in ascending order.
Input:
Sr.no. name    age
1.       Alex.     30
2.       John.     27
3.       Peter.    29
4.       Klaus.    33
Output:
Sr.no. name    age
2.       John.     27
3.       Peter.    29
1.       Alex.      30
4.       Klaus.    33

45). Python Pandas program to replace John with Jim.
Input:
Sr.no. name  age
1.       Alex.    30
2.       John.   27
3.       Peter.  29
4.       Klaus.  33
Output:
Sr.no. name   age
1.       Alex.     30
2.       Jim.       27
3.       Peter.    29
4.       Klaus.    33

46). Python Pandas program to delete records for John.
Input:
Sr.no. name   age
1.       Alex.    30
2.       John.    27
3.       Peter.   29
4.       Klaus.   33
Output:
Sr.no. name age
1.       Alex.   30
3.       Peter.  29
4.       Klaus.  33

47). Python Pandas program to add a new column in a DataFrame.
Input:
Sr.no. name  age
1.       Alex.    30
2.       John.   27
3.       Peter.   29
4.       Klaus.   33
Output:
Sr.no. name   age. Salary
1.       Alex.     30.   50000
2.       John.    27.   65000
3.       Peter.   29.   58000
4.       Klaus.   33.   66000

48). Python Pandas program to iterate over rows in a DataFrame.
Input:
A=[{name:Yash, percentage:78},{name:Rakesh, percentage: 80},{
name: Suresh, percentage:60}]
Output:
Yash      78
Rakesh  80
Suresh   60

49). Python Pandas program to get a list of column headers from the DataFrame.
Input:
A={name:[Virat,Messi, Kobe], sport:[cricket, football, basketball]}
Output:
[name, sport]

50). Python Pandas program to rename columns of a given DataFrame.
Input:
C1. C2. C3
1. 6. 8
3. 8. 2
9. 0. 6
Output:
A. B. C
1. 6. 8
3. 8. 2
9. 0. 6

51). Python Pandas program to change the order of columns in a DataFrame.
Input:
Sr.no. name age. Salary
1.       Alex.   30.  50000
2.       John.  27.  65000
3.       Peter. 29.  58000
4.       Klaus. 33.  66000
Output:
Sr.no. name Salary   Age
1.       Alex.   50000.  30
2.       John.  65000   27
3.       Peter. 58000.   29
4.       Klaus. 66000   33

52). Python Pandas program to write a DataFrame to a CSV file using a tab separator.
Input:
Sr.no. name  age. Salary
1.       Alex.    30.   50000
2.       John.   27.   65000
3.       Peter.  29.   58000
4.       Klaus.  33.   66000
Output:
Sr.no\tname\tage\tSalary
1\tAlex\t30\t50000
2\tJohn\t27\t65000
3\tPeter\t29\t58000
4\tKlaus\t33\t66000

53). Python Pandas program to count Country wise population from a given data set (columns of a data set- Country, population).
Output:
Country. Population
China.     57289229
India.      49262728
.
.
.

54). Python Pandas program to replace all the NaN values with a scaler in a column of a Dataframe.
Input:
Sr.no. name  age
1.       Alex.    30
2.       John.   np.nan
3.       Peter.  29
4.       Klaus.  np.nan
Output:
Sr.no. name  age
1.       Alex.    30
2.       John.   25
3.       Peter.  29
4.       Klaus.  25

55). Python Pandas program to count the NaN values in a Dataframe.
Input:
Sr.no. name   age
1.       Alex.    30
2.       John.   np.nan
3.       Peter.   29
4.       Klaus.  np.nan
Output:
2

56). Python Pandas program to shuffle rows in a DataFrame.
Input:
Sr.no. name  age.   Salary
1.       Alex.    30.     50000
2.       John.    27.    65000
3.       Peter.   29.     63000
4.       Klaus.   33.    59000
Output:
Sr.no. name  age.  Salary
2.       John.   27.    65000
4.       Klaus.  33.    59000
1.       Alex.   30.     50000
3.       Peter.  29.     63000

57). Python Pandas program to rename a column in a DataFrame.
Input:
Rank. name  age.  Salary
1.       Alex.    30.    50000
2.       John.   27.    65000
3.       Peter.  29.    63000
4.       Klaus.  33.    59000
Output:
Sr.no. name age. Salary
1.       Alex.   30.   50000
2.       John.  27.   65000
3.       Peter. 29.   63000
4.       Klaus. 33.   59000

58). Python Pandas program to get a list of records in a  column of a DataFrame.
Input:
Sr.no. name age. Salary
1.       Alex.   30.   50000
2.       John.  27.   65000
3.       Peter. 29.   63000
4.       Klaus. 33.   59000
Output:
[Alex, John, Peter, Klaus]

59). Python Pandas program to find the row where the value of a column is maximum.
Input:
Sr.no. name age. Salary
1.       Alex.   30.   50000
2.       John.  27.   65000
3.       Peter. 29.   63000
4.       Klaus. 33.   59000
Output: Row where salary is maximum 2

60). Python Pandas program to find the row where the value of a given column is minimum.
Input:
Sr.no. name age. Salary
1.        Alex.   30.  50000
2.        John.  27.  65000
3.        Peter. 29.  63000
4.        Klaus. 33.  59000
Output= Row where salary is minimum 1

61). Python Pandas program to check whether a column is present in a DataFrame.
Input:
Sr.no. name  age. Salary
1.       Alex.   30.    50000
2.       John.   27.   65000
3.       Peter.  29.   63000
4.       Klaus. 33.    59000
Output:
The company column is not present in DataFrame
The name column is present in DataFrame

62). Python Pandas program to get the datatypes of columns of a DataFrame.
Input:
Sr.no. name   age.  Salary
1.        Alex.    30.    50000
2.        John.   27.    65000
3.        Peter.  29.     63000
4.        Klaus.  33.    59000
Output:
Sr.no. Int64
Name. Object
Age. Int64
Salary. Int64

63). Python Pandas program to convert a list of lists into a Dataframe. 
Input:
[[Virat, cricket],[Messi, football]]
Output:
0 column1 column2
1. Virat.      Cricket
2. Messi.    Football

64). Python Pandas program to find the index of a column from the DataFrame.
Input:
Sr.no. name   age. Salary
1.        Alex.    30.   50000
2.        John.   27.   65000
3.        Peter.  29.   63000
4.        Klaus.  33.   59000
Output: Index number of age is 2

65). Python Pandas program to select all columns except one column in a DataFrame.
Input:
Sr.no. name age.  Salary
1.       Alex.   30.    50000
2.       John.  27.    65000
3.       Peter.  29.   63000
4.       Klaus. 33.    59000
Output:
Sr.no. name   Salary
1.        Alex.   50000
2.        John.  65000
3.        Peter.  63000
4.        Klaus. 59000

66). Python Pandas program to remove the first n rows of a DataFrame. 
Input:
Sr.no. name  age. Salary
1.       Alex.   30.    50000
2.       John.   27.   65000
3.       Peter.  29.   63000
4.       Klaus.  33.   59000
Output:
After removing the first 2 rows
Sr.no. name age.  Salary
3.       Peter.  29.   63000
4.       Klaus.  33.   59000

67). Python Pandas program to remove the last n rows of a given DataFrame.
Input:
Sr.no. name  age. Salary
1.       Alex.   30.    50000
2.       John.  27.    65000
3.       Peter. 29.    63000
4.       Klaus. 33.    59000
Output:
After removing the last 2 rows
Sr.no. name age.  Salary
1.       Alex.   30.   50000
2.       John.  27.   65000

68). Python Pandas program to reverse the order of rows of a given DataFrame.
Input:
Sr.no. name   age. Salary
1.       Alex.     30.    50000
2.       John.    27.    65000
3.       Peter.   29.    63000
4.       Klaus.   33.    59000
Output:
Sr.no. name age. Salary
4.       Klaus. 33.   59000
3.       Peter. 29.   63000
2.       John.  27.   65000
1.       Alex.  30.   50000.

69). Python Pandas program to reverse the order of columns in a DataFrame.
Input:
Sr.no. name  age.  Salary
1.       Alex.    30.    50000
2.       John.    27.    65000
3.       Peter.   29.    63000
4.       Klaus.   33.    59000
Output:
Salary. age. Name. Sr.no.
50000. 30.    Alex.     1
65000. 27.   John.     2
63000. 29.   Peter.    3
59000. 33.   Klaus.    4

70). Python Pandas program to select columns by the object datatype from the DataFrame.
Input:
Sr.no. name  age. Salary
1.        Alex.  30.    50000
2.        John.  27.   65000
3.        Peter. 29.   63000
4.        Klaus. 33.   59000
Output:
Select string columns
Name
Alex
John
Peter
Klaus

71). Python Pandas program to convert continuous values of a column of a DataFrame to categorical.
Input:
{Student_id:[1,2,3,4], marks:[30,50,70,80]}
Output:
0. Marks
1. Fail
2. 2nd class
3. 1st class
4. 1st class with distinction

72). Python Pandas program to convert all the string values in the DataFrame to uppercases.
Input:
0. cricket
1. Yes
2. pass
3. FAIL
Output:
0. Cricket
1. Yes
2. Pass
3. Fail

73). Python Pandas program to check whether only the upper case is present in a column of a DataFrame.
Input:
0. Name
1. Kate
2. Jason
3. ROBERT
4. MARK
5. Dwyane
Output: 
0. Name.    Name
1. Kate.      False
2. Jason.     False
3. ROBERT True
4. MARK.   True
5. Dwyane. False

74). Python Pandas program to check whether only the lower case is present in a given column of a DataFrame .
Input:
0. Name
1. kate
2. jason
3. ROBERT
4. MARK
5. dwyane
Output:
0. Name.    Name
1. Kate.       True
2. Jason.     True
3. ROBERT  False
4. MARK.    False
5. dwyane. True

75). Python Pandas program to check whether only numeric values are present in a column of a DataFrame.

Input: 
0. Marks
1. Pass
2. 88
3. 2nd class
4. 90
5. Distinction
Output:
0. Marks.           Marks
1. Pass.              False
2. 88.                  True
3. 2nd class.      False
4. 90.                  True
5. Distinction.    False

76). Python Pandas program to check whether only alphabetic values present in a column of a DataFrame.
Input:
0. Marks
1. Pass
2. 88
3. First class
4. 90
5. Distinction
Output:
0. Marks.           Marks
1. Pass.              True
2. 88.                  False
3. First class.      False
4. 90.                  False
5. Distinction.    True

77). Python Pandas program to get the length of the integer of a column in a DataFrame.
Input:
0. Sales
1. 55000
2. 75000
3. 330000
4. 10000
Output:
0. Sales.        Sales_length
1. 55000.       5
2. 75000.       5
3. 330000.     6
4. 1000.         4

78). Python Pandas program to extract email from a specified column of a given DataFrame.
Input:
0. Company_mail
1. TCS. tcs@yahoo.com
2. Apple. apple@icloud.com
3 Google. google@gmail.com
Output:
0. Company_mail                         email
1. TCS. tcs@yahoo.com               tcs@yahoo.com
2. Apple. apple@icloud.com       apple@icloud.com
3 Google.google@gmail.com     google@gmail.com

79). Python Pandas program to extract the hash attached word from Twitter text from the specified column of a given DataFrame.
Input:
0. Tweets
1. Pune #love
2. #boycottmovie
3. enjoying #peace
Output:
0. Tweets                   extracted_word
1. Pune #love.           love
2. #boycottmovie.     boycottmovie
3. enjoying #peace   peace

80). Python Pandas program to extract only words from a column of a DataFrame.
Input:
Name      Address
Ramesh.   297 shukrawar peth
Suresh.     200 ravivar peth
Sanket.     090 shanivar peth
Output:
Name       Address                       Only_words
Ramesh.   297 shukrawar peth    shukrawar peth
Suresh.     200 ravivar peth          ravivar peth
Sanket.     090 shanivar peth        shanivar peth

81). Python Pandas program to join the two Dataframes along rows.
Input:
D1
Id Name. Age
1. Yash.     30
2. Gaurav.  27
3. Sanket.  28
D2
Id. Name.   Age
4. Atharva.  26
3. Tanmay.  22
Output:
Id Name.     Age
1. Yash.        30
2. Gaurav.    27
3. Sanket.    28
4. Atharva.  26
3. Tanmay.  22

82). Python Pandas program to join the two Dataframes along columns.
Input:
D1
Id Name.    Age
1. Yash.       30
2. Gaurav.   27
3. Sanket.   28
D2
Id.  Name.    Age
4.   Atharva.  26
3.   Tanmay.  22
Output:
Id  Name.    Age  Id.  Name.       Age
1.   Yash.      30.    4.   Atharva.    26
2.   Gaurav.  27.    3.  Tanmay.     22
3.   Sanket.   28

83). Python Pandas program to join the two Dataframes using the common column of both Dataframes.
Input:
D1
Id.  Name        marks1
S1. Ketan.       90
S2. Yash.         87
S3. Abhishek  77
D2
Id.  Name.    Marks2
S2. Yash.     70
S4. Gaurav. 65
Output:
Id.  Name. Marks1. name. Marks2
S2.  Yash.   87.         Yash.   70

84). Python Pandas program to merge two Dataframes with different columns.

85). Python Pandas program to detect missing values from a  DataFrame. 
Input:
Sr.no. name   age
1.       Alex.     30
2.       John.    np.nan
3.       Peter.    29
4.       Klaus.   np.nan
Output:
Sr.no. name   age
False   False.   False
False   False   True
False   False   False
False   False   True

86). Python Pandas program to identify the columns from the DataFrame which have at least one missing value.
Input:
Sr.no. name     age
1.       Alex.      30
2.       np.nan.  np.nan
3.       Peter.     29
4.       Klaus.     np.nan
Output:
Sr.no. False
Name. True
Age. True

87). Python Pandas program to count the number of missing values in each column of a DataFrame.
Input:
Sr.no. name     age
1.       Alex.       30
2.       np.nan.  np.nan
3.       Peter.     29
4.       Klaus.     np.nan
Output:
Sr.no. 0
Name. 1
Age. 2

88). Python Pandas program to drop the rows where at least one element is missing in a DataFrame.
Input:
Sr.no. name      age
1.        Alex.       30
2.        np.nan.   np.nan
3.        Peter.      29
4.        Klaus.     np.nan
Output:
Sr.no. name   age
1.        Alex.    30
3.        Peter.   29

89). Python Pandas program to drop the columns where at least one element is missing in a DataFrame.
Input:
Sr.no. name     age
1.        Alex.      30
2.        np.nan.  np.nan
3.        Peter.     29
4.        Klaus.     np.nan
Output:
Sr.no.
1
2
3
4

90). Python Pandas program to drop the rows where all elements are missing in a DataFrame.
Input:
Sr.no.           name    age
1.                 Alex.     30
np.nan        np.nan. np.nan
3.                 Peter.   29
4                 Klaus.   np.nan
Output:
Sr.no. name   age
1.        Alex.    30
3.        Peter.  29
4.        Klaus.  np.nan

91). Python Pandas program to replace NaNs with the value from the previous row in a DataFrame.
Input:
Sr.no. name     age
1.       Alex.      30
2.       np.nan.  np.nan
3.       Peter.     29
4.       Klaus.     22
Output:
Sr.no. name   age
1.       Alex.    30
2.       Alex.    30
3.       Peter.   29
4.       Klaus.   22

92). Python Pandas program to replace NaNs with the value from the next row in a DataFrame.
Input:
Sr.no. name     age
1.       Alex.       30
2.       np.nan.   np.nan
3.       Peter.      29
4.       Klaus.      22
Output:
Sr.no. name   age
1.       Alex.     30
2.       Peter.    29
3.       Peter.    29
4.       Klaus.    22

93). Python Pandas program to replace NaNs with mean in a DataFrame.
Input:
Sr.no. name     age
1.       Alex.       30
2.       np.nan.   np.nan
3.       Peter.     29
4.       Klaus.     22
Output:
Sr.no. name   age
1.       Alex.     30
2.       np.nan. 27
3.      Peter.    29
4.      Klaus.    22

94). Python Pandas program to replace the missing values with the most frequent values present in each column of a given DataFrame.
Input:
Sr.no. name    age
1.       Alex.      30
2.       np.nan.  np.nan
3.       Peter.     29
4.       Klaus.     22
5.       Stefen.    22
Output:
Sr.no. name    age
1.       Alex.      30
2.       np.nan.  22
3.       Peter.     29
4.       Klaus.     22
5.       Stefen.   22

95). Python Pandas program to replace NaNs with the median value in a DataFrame.
Input:
Sr.no. name    age
1.       Alex.     30
2.       np.nan. np.nan
3.       Peter.    29
4.       Klaus.    22
Output:
Sr.no. name  age
1.       Alex.    30
2.       John.   29
3.       Peter.  29
4.       Klaus.  22

96). Python Pandas program to import a CSV file.

97). Python Pandas program to import an xlsx file.