Write a Pandas program to extract items at given positions of a given series
- برمجة بايثون
- 2021-09-10
- mhanasmh00489829403
الأجوبة
import pandas as pd
num_series = pd.Series(list('2390238923902390239023'))
element_pos = [0, 2, 6, 11, 21]
print("Original Series:")
print(num_series)
result = num_series.take(element_pos)
print("\nExtract items at given positions of the said series:")
print(result)
Sample Output:
Original Series: 0 2 1 3 2 9 3 0 4 2 5 3 6 8 7 9 8 2 9 3 10 9 11 0 12 2 13 3 14 9 15 0 16 2 17 3 18 9 19 0 20 2 21 3 dtype: object Extract items at given positions of the said series: 0 2 2 9 6 8 11 0 21 3 dtype: object
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال