Am not sure if my quest is well framed but here it is.
here in this code i read the csv file and assign it to the variable australia_analysis specifying that the location column should be AUS
this is the output when i print it
How can i assign the dataframe to the variable under two conditions that the location should be AUS and the subject should be MEASLES so that i only get rows that satisfy the condition
You can combine multiple conditions with &:
loaded_data.loc[(loaded_data['LOCATION'] == 'AUS') & (loaded_data['SUBJECT'] == 'MEASLES')]
You can filter based on multiple columns using this code
import pandas as pd
df = pd.DataFrame([{"a":1,"b":1},{"a":1,"b":2},{"a":2,"b":2},{"a":2,"b":1}])
df2 = df[(df["a"] ==1) & (df["b"]==2)]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.