Skip to Content
Pandas for Everyone: Python Data Analysis, First Edition
book

Pandas for Everyone: Python Data Analysis, First Edition

by Daniel Y. Chen
December 2017
Beginner to intermediate
410 pages
12h 45m
English
Addison-Wesley Professional
Content preview from Pandas for Everyone: Python Data Analysis, First Edition

I. Lists

Lists are a fundamental data structure in Python. They are used to store heterogeneous data, and are created with a pair of square brackets, [].

my_list = ['a', 1, True, 3.14]

We can subset the list using square brackets and provide the index of the item we want.

# get the first item print(my_list[0])

a

We can also pass in a range of values (Appendix L).

# get the first 3 values print(my_list[:3])

['a', 1, True]

We can reassign values when we subset values from the list.

# reassign the first value my_list[0] = 'zzzzz' print(my_list)

['zzzzz', 1, True, 3.14]

Lists are objects in Python (Appendix S), so they will have methods that they can perform. For example, we can append values to the list.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pandas for Everyone: Python Data Analysis, 2nd Edition

Pandas for Everyone: Python Data Analysis, 2nd Edition

Daniel Y. Chen

Publisher Resources

ISBN: 9780134547046Purchase book