﻿ Pandas Practice Dataset1: Select a series from a DataFrame and print - w3resource

# Pandas Practice Set-1: Select a series from a DataFrame and print

## Pandas Practice Set-1: Exercise-3 with Solution

Write a Pandas program to select a series from diamonds DataFrame. Print the content of the series.

Sample Solution :

Python Code :

``````import pandas as pd
print(diamonds['carat'])
``````

Sample Output:

```runfile('C:/Users/User/.spyder-py3/temp.py', wdir='C:/Users/User/.spyder-py3')
0        0.23
1        0.21
2        0.23
3        0.29
4        0.31
5        0.24
6        0.24
7        0.26
8        0.22
9        0.23
10       0.30
11       0.23
12       0.22
13       0.31
14       0.20
15       0.32
16       0.30
17       0.30
18       0.30
19       0.30
20       0.30
21       0.23
22       0.23
23       0.31
24       0.31
25       0.23
26       0.24
27       0.30
28       0.23
29       0.23

53910    0.70
53911    0.57
53912    0.61
53913    0.80
53914    0.84
53915    0.77
53916    0.74
53917    0.90
53918    0.76
53919    0.76
53920    0.70
53921    0.70
53922    0.70
53923    0.73
53924    0.73
53925    0.79
53926    0.71
53927    0.79
53928    0.79
53929    0.71
53930    0.71
53931    0.71
53932    0.70
53933    0.70
53934    0.72
53935    0.72
53936    0.72
53937    0.70
53938    0.86
53939    0.75
Name: carat, Length: 53940, dtype: float64
```

Python Code Editor:

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

What is the difficulty level of this exercise?

﻿

## Python: Tips of the Day

Python: The Zip() Function

```>>> students = ('John', 'Mary', 'Mike')
>>> ages = (15, 17, 16)
>>> scores = (90, 88, 82, 17, 14)
>>> for student, age, score in zip(students, ages, scores):
...     print(f'{student}, age: {age}, score: {score}')
...
John, age: 15, score: 90
Mary, age: 17, score: 88
Mike, age: 16, score: 82
>>> zipped = zip(students, ages, scores)
>>> a, b, c = zip(*zipped)
>>> print(b)
(15, 17, 16)
```