Dataframes¶
To correlate our various measurements, we want some table-like data structure, so we import Dataframes:
Crating Dataframes¶
A dataframe can be created from a list of series, where each series forms a row in the resulting table.
Output
A dataframe can also be created from a dictionary of series where each series forms a column in the resulting table.
measurements = DataFrame(
data={
sneeze_counts.name: sneeze_counts,
temperatures.name: temperatures,
humidities.name: humidities
}
)
print(measurements)
Output
Turn around¶
To flip rows and columns, dataframes can be transposed using the T
-property:
column_wise = DataFrame(data=temperatures)
row_wise = column_wise.T
print(column_wise)
print() # Add a blank line as separator
print(row_wise)
Output
Don’t forget to store the transposed dataframe in a new variable (or overwrite the old one), as the original will not be changed by the transposition.
Key Points
- Dataframes represent 2-dimensional (tabular) data
- Each column in a dataframe is a series
- Dataframes have row and column indices
- Dataframes may be transposed to switch rows and columns