w3resource

Pandas Data Series: Create and display a one-dimensional array-like object containing an array of data

Pandas: Data Series Exercise-1 with Solution

Write a Pandas program to create and display a one-dimensional array-like object containing an array of data.

Sample Solution :

Python Code :

import pandas as pd
ds = pd.Series([2, 4, 6, 8, 10])
print(ds)

Sample Output:

0     2                                                                
1     4                                                                
2     6                                                                
3     8                                                                
4    10                                                                
dtype: int64

Python Code Editor:


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Python Pandas Data Series, DataFrame Exercises Home.
Next: Write a Pandas program to convert a Panda module Series to Python list and it’s type.

What is the difficulty level of this exercise?

Test your Python skills with w3resource's quiz



Python: Tips of the Day

Function argument unpacking in Python.

Example:

def tips_func(x, y, z):
  print(x, y, z)
  
tuple_val = (2, 0, 2)
dict_val = {'x': 3, 'y': 2, 'z': 1}
tips_func(*tuple_val)
tips_func(**dict_val)

Output:

2 0 2
3 2 1