From the course: Python Data Analysis

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Data classes

Data classes

- [Instructor] Let us look at Python data structures from the perspective of a data scientist or a data analyst. What are the options to store tabular data, such as a table of famous people with their names and birthdays? A list of Python dicts is certainly a possibility. It's easy to access the columns by the key and to query the rows using comprehensions. For instance, famous people with a birthday on July 15. Another possibility are tuples, or even better, the namedtuples from the collections module in the Python starter library. With these, we create a specialized tuple that associates labels with columns. The syntax to create a person is intuitive. We can also meet the labels. The columns can be accessed with a dot notation of Python object attributes. Although regular tuple indices would also work. We can convert these tuples from and to a dictionary using ** unpacking, and the namedtuple method asdict. If you're wondering about the underscore is there to avoid confusion in case…

Contents