Sorry for the noob question. I have a bunch of stocks in a sqlite3 database: When I print the df, it gives me the following (where each stock_id refers to a unique stock, e.g APPL): I need to target each unique stock_id individually, and get the prior close. I know if each stock was in its own separate dataframe, I