I find myself having to create dataframes which are filters of a larger dataframe quite often and I was wondering whether there is a way to program Python to do this for me?
For example, the dataset I'm working on now is app version data, looks like:
user_id | session_id | timestamp | time_seconds | app_version
001 | 123 | 2014-01-01| 251 | v1
002 | 845 | 2014-01-01| 514 | v1
003 | 741 | 2014-01-02| 141 | v1
003 | 477 | 2014-01-03| 221 | v2
004 | 121 | 2014-01-03| 120 | v2
005 | 921 | 2014-01-04| 60 | v3
...
I need to separate out the different app versions so each version has its own dataframe, and currently I'm doing it like this:
v1 = all_data[all_data['app_version'] == 'v1']
v2 = all_data[all_data['app_version'] == 'v2']
v3 = all_data[all_data['app_version'] == 'v3']
This seems very repetitive, is there a for loop I can write to do this for me?
df.groupby('app_version')