Write a Pandas program to find the positions of numbers that are multiples of 5 of a given series

  • برمجة بايثون

Write a Pandas program to find the positions of numbers that are multiples of 5 of a given series

الأجوبة

import pandas as pd
import numpy as np
num_series = pd.Series(np.random.randint(1, 10, 9))
print("Original Series:")
print(num_series)
result = np.argwhere(num_series % 5==0)
print("Positions of numbers that are multiples of 5:")
print(result)

Sample Output:

Original Series:
0    1
1    9
2    8
3    6
4    9
5    7
6    1
7    1
8    1
dtype: int64
Positions of numbers that are multiples of 5:
[]
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...