title: Pandas: calculate mean by specific value in column with a for loop
body: <p>I have a dataset which has consecutive rows with a 'marker' (numbers 0,1,2,....) which indicates that all of these rows belong to the same 'picture'(e.g. marker = [0,0,0,0,1,1,1,2,2,2,2,2,....]). Now I want my programme to give me the mean of each 'picture', e.g all with number = 0 belong to picture 0 and calculate the mean of the whole data frame within that marker. So far I tried this:</p>
  
  <pre><code>###Read data in: 
  df = pd.read_csv(path_i, sep = ",")
  
  #### Calculate means per picture: 
  
  number = 0
  
  for i in df:
        picture = df.marker[number]
        means = df.mean(picture)
        number = number + 1
  </code></pre>
  
  <p>my code gives me output: however it is the same for every line: I think since im expecting about 96 pictures, it gives me the mean of the whole data frame.</p>
  
  <pre><code>Unnamed: 0       18547.000000
  index            18548.000000
  pos_time        341778.900067
  pos_x              -95.375306
  pos_y              -64.948367
  pup_time        341778.900067
  pup_diameter         3.116594
  marker              48.336649
  which_AOI            1.637822
  fixation            17.559536
  dtype: float64
  </code></pre>