DataFrame
Let’s learn about grabbing columns, rows, and specific elements from a DataFrame.
A very simple way to think about a DataFrame is as a bunch of Series that share the same index. A DataFrame is a rectangular table of data that contains an ordered collection of columns, each of which can be a different value type (numeric, string, boolean, and so on). A DataFrame has both rows and column indexes. It can be thought of as being a dictionary of Series, all of which share the same index (any row or column).
Let’s create a few DataFrames to learn more about them.
For our DataFrame, we’ll create two labels or indexes:
- Our index will be for rows
r1
tor10
. - Our columns will be for columns
c1
toc10
.
In the code below, we’ll use split()
to create a list and then use arange()
and reshape()
together to create a 2-D array (matrix).
Get hands-on with 1400+ tech skills courses.