Check whether elements in the series are equal or not

In this python pandas program, we will check whether elements in the series are equal or not.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create two series using pd.Series().
  3. Check whether elements in the series are equal or not using ” == “.
  4. Print the output.
				
					import pandas as pd
df1 = pd.Series([1,6,9,5])
df2 = pd.Series([5,2,4,5])
print("Equals:")
print(df1 == df2)
				
			

Output :

				
					Equals:
0    False
1    False
2    False
3     True
dtype: bool
				
			

divide two series

check whether elements in the series are greater than other series

Program to divide two series

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

Steps to solve the program
  1. Import pandas library as pd.
  2. Create two series using pd.Series().
  3. Now divide 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    0.20
1    3.00
2    2.25
3    1.00
dtype: float64
				
			

multiply two series

check whether elements in the series are equal or not

Program to multiply two series

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

Steps to solve the program
  1. Import pandas library as pd.
  2. Create two series using pd.Series().
  3. Now multiply 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     5
1    12
2    36
3    25
dtype: int64
				
			

subtract two series

divide two series

Program to subtract two series

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

Steps to solve the program
  1. Import pandas library as pd.
  2. Create two series using pd.Series().
  3. Now subtract 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   -4
1    4
2    5
3    0
dtype: int64
				
			

add two series

multiply two series

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

Program to create an array using dtype as complex

In this python numpy program, we will create an array using dtype as complex.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array() and set dtype = complex.
  3. It will create an array of complex numbers.
  4. Print the output.
				
					import numpy as np
a = np.array([5,4], dtype = complex)

print(a)
				
			

Output :

				
					[5.+0.j 4.+0.j]
				
			

convert a tuple into an array.

Program to convert a tuple into a NumPy array

In this python numpy program, we will convert a tuple into a NumPy array.

Steps to solve the program
  1. Import the numpy library as np.
  2. Convert a tuple into an array using np.asarray().
  3. Print the output.
				
					import numpy as np
x = np.asarray((5,7,0))

print(x)
				
			

Output :

				
					[5 7 0]
				
			

round off the elements in an array using ceil function.

create an array using dtype as complex.

Program to round off the elements in an array using ceil function

In this python numpy program, we will round off the elements in an array using ceil function.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Round off the elements in an array using np.ceil().
  4. It will round up a decimal number to the next value i.e 12.5 will be 13.
  5. Print the output.

				
					import numpy as np
arr = np.array([12.202, 90.23120, 123.88, 23.202])  

print(np.ceil(arr)
				
			

Output :

				
					[ 13.  91. 124.  24.]
				
			

round off the elements in an array using the floor function.

convert a tuple into an array.