0

I have a dataframe that looks like this:

AP  date            val1    val2    count   ID
0   FCN 2018-03-14 00:00:00.000 1.8 75775   246885  14231
1   ATL 2018-03-13 23:00:00.000 0.5 13055   2   34331
2   SIN 2018-03-14 00:00:00.000 0.3 8633    1   37106
3   ATL 2018-03-14 00:00:00.000 60.7    13609   670 81359
4   ATL 2018-03-13 23:00:00.000 0.5 17530   5   26969
5 . . .
6 . .

Background:

I am able to create loop to generate a plot for each of the IDs For example :

for IDs in list_of_ids:
    ind = np.arange(3)
    width = 0.3
    temp = df5[(df5[‘ID’] == str(ID))]
    x = temp['timestamp']
    y = temp['count']
    y1 = temp[‘val1’]
    y2 = temp[‘val2’]
    …     
plt.close()

This gives me 1 plot for every different ID so I can create a histograms accordingly.

Problem:

I want to be able to create the same plots above for every airport code too. Meaning ATL should have a set of plots above, along with FCN etc etc . I could create many dataframes that only have 1 AP but that would be taxing especially if I have a dataframe that already has all the data in it.

My idea is to add another loop, like this:

for APs in list_of_APs:
    for IDs in list_of_IDs:
       ind = np.arange(3)
       width = 0.3
       **temp = df5[(df5[‘ID’] == str(ID)) and df5[‘AP’] == str(AP))]**
       x = temp['timestamp']
       y = temp['count']
       y1 = temp[‘val1’]
       y2 = temp[‘val2’]
       …     

But I cannot get the syntax right to create this object

temp = df5[(df5[‘ID’] == str(ID)) and df5[‘AP’] == str(AP))]

chowpay
  • 1,515
  • 6
  • 22
  • 44

0 Answers0