G3. Defining a tabular view of a data collection Flashcards
What is a DataFrame?
Tabular data structure, with rows and columns. Rows have a specific index to access them, which can be any name or value. In Pandas, the columns are called Series, a special type of data, which consists of a list of several values, where each value has an index.
Define a DataFrame that shows the readings of home appliances energy consumption when they are used according to the following schema:
<applianceName, initialdate, initialhour, finaldate, finalhour, consumedWatts>
import pandas as pd
data = {
‘applianceName’:[‘Refrigerator’, ‘Washing Machine’, ‘Air Conditioner’]
‘initialdate’:[,]
‘initialhour’:[,]
‘finaldate’:[,]
‘finalhour’:[,]
‘consumedWatts (kWh)’:[1.5, 2.0, 3.5]
}
df=pd.DataFrame(data)