From the course: Python Data Analysis
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Data classes - Python Tutorial
From the course: Python Data Analysis
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.