Day: April 5, 2021

Pandas Example – Write a Pandas program to get the powers of an array values element-wise

(Python Example for Beginners)   Write a Pandas program to get the powers of an array values element-wise. Note: First array elements raised to powers from second array Sample data: {‘X’:[78,85,96,80,86], ‘Y’:[84,94,89,83,86],’Z’:[86,97,96,72,83]}   Sample Solution : Python Code : import pandas as pd df = pd.DataFrame({‘X’:[78,85,96,80,86], ‘Y’:[84,94,89,83,86],’Z’:[86,97,96,72,83]}); print(df) Sample Output: X Y Z 0 78 84 …

Pandas Example – Write a Pandas program to check the equality of two given series

(Python Example for Beginners)   Write a Pandas program to check the equality of two given series.   Sample Solution : Python Code : import pandas as pd nums1 = pd.Series([1, 8, 7, 5, 6, 5, 3, 4, 7, 1]) nums2 = pd.Series([1, 8, 7, 5, 6, 5, 3, 4, 7, 1]) print(“Original Series:”) print(nums1) print(nums2) …

Pandas Example – Write a Pandas program to convert given series into a dataframe with its index as another column on the dataframe

(Python Example for Beginners)   Write a Pandas program to convert given series into a dataframe with its index as another column on the dataframe.   Sample Solution : Python Code : import numpy as np import pandas as pd char_list = list(‘ABCDEFGHIJKLMNOP’) num_arra = np.arange(8) num_dict = dict(zip(char_list, num_arra)) num_ser = pd.Series(num_dict) df = num_ser.to_frame().reset_index() …