Concatenate DataFrames
Let's assume you have gathered multiple datasets about your environment for the same time period, and would like to analyze them.
The first step is to combine the datasets into one, to comfortably work with them.
You'll work on combining the three DataFrames temperature
, humidity
, and windspeed
.
Cet exercice fait partie du cours
Analyzing IoT Data in Python
Instructions
- Rename the columns of the DataFrames to match
"temperature"
,"humidity"
and"windspeed"
. - Create a list of DataFrames
df_list
containing the DataFramestemperature
,humidity
, andwindspeed
, in this order. - Concatenate the list of DataFrames into one and name that
environment
. Each DataFrame should get it's own column. - Print the head of the combined DataFrame.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Rename the columns
temperature.columns = [____]
humidity.columns = ____
____
# Create list of DataFrames
df_list = [____]
# Concatenate files
environment = pd.concat(____, ____)
# Print first rows of the DataFrame
____