w3resource

Pandas: 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

Python: Membership Testing in a Collection

>>> a = ('one', 'two', 'three', 'four', 'five')
>>> if 'one' in a:
...     print('The tuple contains one.')
... 
The tuple contains one.
>>> b = {0: 'zero', 1: 'one', 2: 'two', 3: 'three'}
>>> if 2 in b.keys():
...     print('The dict has the key of 2.')
... 
The dict has the key of 2.