import pandas as pd df: pd.DataFrame = pd.read_csv("avocado.csv") albany_df = df[df["region"] == "Albany"] # albany_df = df[df["region"] == "Albany"].copy() print(albany_df)
males = df[(df[Gender]=='Male') & (df[Year]==2014)]
To store your dataframes in a dict using a for loop:
from collections import defaultdict dic={} for g in ['male', 'female']: dic[g]=defaultdict(dict) for y in [2013, 2014]: dic[g][y]=df[(df[Gender]==g) & (df[Year]==y)] #store the DataFrames to a dict of dict
References
https://pythonprogramming.net/introduction-python3-pandas-data-analysis/
https://stackoverflow.com/questions/22086116/how-do-you-filter-pandas-dataframes-by-multiple-columns