Healthcare in Different States Question 8

We’ll now use a for loop to separate the dataset into a dataset for each state:

datasets = []
for state in states:
  datasets.append(chest_pain[chest_pain['Provider State'] == state][' Average Covered Charges '].values)

datasets now contains 50 datasets — one for each state.

Can someone explain this for loop

I understand we are appending from chest_pains where provider state == state and we get the values from average charges.

But I don’t get the syntax. Why is there so many ?

Also for the output datasets, for each state is it a list within the datasets list?

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.