Professional Documents
Culture Documents
Prac2.ipynb (Auto-R) - JupyterLab
Prac2.ipynb (Auto-R) - JupyterLab
# a. Create a series with 5 elements and display sorted series on index and values separatel
series_a = pd.Series([3, 1, 5, 2, 4], index=['e', 'a', 'c', 'b', 'd'])
print("Original Series:")
print(series_a)
print("\nSorted Series on Index:")
print(series_a.sort_index())
print("\nSorted Series on Values:")
print(series_a.sort_values())
# Find the minimum and maximum ranks assigned to the values using 'first' and 'max' methods
print("\nMinimum Rank (assigned to values using 'first' method):")
print(series_b.rank(method='first', ascending=True))
print("\nMaximum Rank (assigned to values using 'max' method):")
print(series_b.rank(method='max', ascending=True))
# c. Display the index value of the minimum and maximum element of a Series
print("\nIndex value of the minimum element:", series_b.idxmin())
print("Index value of the maximum element:", series_b.idxmax())
Original Series:
e 3
a 1
c 5
b 2
d 4
dtype: int64
In [ ]: