# tuples are different
tuple1 = (1,2,3,4) # we create tuples with parentheses
tuple2 = tuple1 # we copy the tuple1 into another variable tuple2
# When we add to tuple2, we are NOT changing the original tuple2 variable
# we are creating a NEW tuple that has the same elements as tuple2 with addition of 5, and assigning the NEW tuple to the variable tuple2
tuple2 += (5,)
print(tuple1)
print(tuple2)
# A DataFrame can be created from a dictionary of tuples
# Each key-value pair in the dictionary corresponds to a column in the DataFrame
# The key is the column label and the tuple is the column data
data = {
'mag': (1,1,3,3),
'date': ('April 11 2024','April 11 2024','April 12 2024','April 13 2024'),
'inj' : (1,2,100,200)
}
tdata = pd.DataFrame(data)
############################################33
### SIDE BAR - A mini lesson on Zip():
# Zip() is used to pair elements
# say you have two lists
# Using zip to pair elements from two lists
list1 = ['a', 'b', 'c']
list2 = [1, 2, 3]
paired = list(zip(list1, list2))
print(paired) # Output: [('a', 1), ('b', 2), ('c', 3)]
## END
#################################################
# Combine the 'the 'mag' and 'date' columns to tuples in a new column called key
tdata['key'] = list(zip(tdata['mag'], tdata['date']))
# Now you can use the 'key' column to group the data
grouped = tdata.groupby('key')['inj'].sum() # sum injuries for each unique combination of mag-date
print(tdata)
print(grouped)