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
.
This exercise is part of the course
Analyzing IoT Data in Python
Exercise 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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample 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
____