title: python dask dataframes - concatenate groupby.apply output to a single data frame
body: <p>I am using dask dataframe.groupby().apply() 
  and get a dask series as a return value. 
  I am each group to a list triplets such as (a,b,1) and wish then to turn all the triplets into a single dask data frame </p>
  
  <p>I am using this code in the end of the mapping function to return the triplets as a dask df </p>
  
  <pre><code>#assume here that trips is a generator for tripletes such as you would produce from itertools.product([l1,l2,l3])
  trip = list(itertools.chain.from_iterable(trip))
  df = pd.DataFrame.from_records(trip)
  return dd.from_pandas(df,npartitions=1)
  </code></pre>
  
  <p>then when I try to use something similar to <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html" rel="nofollow noreferrer">pandas concat</a> with <a href="http://dask.pydata.org/en/latest/array-stack.html" rel="nofollow noreferrer">dask concatenate</a></p>
  
  <p>Assume the result of the apply function is the variable result. 
  I am trying to use 
  import dask.dataframe as dd 
  dd.concat(result, axis=0 </p>
  
  <p>and get the error </p>
  
  <blockquote>
    <p>raise TypeError("dfs must be a list of DataFrames/Series objects")
    TypeError: dfs must be a list of DataFrames/Series objects</p>
  </blockquote>
  
  <p>But when I check for the type of result using </p>
  
  <pre><code>print type(result)
  </code></pre>
  
  <p>I get</p>
  
  <blockquote>
    <p>output: class 'dask.dataframe.core.Series'</p>
  </blockquote>
  
  <p>What is the proper way to apply a function over groups of dask groupby object and get all the results into one dataframe? </p>
  
  <p>Thanks</p>
  
  <p>edit:--------------------------------------------------------------
  in order to produce the use case, assume this fake data generation </p>
  
  <pre><code>import random
  import pandas as pd
  import dask.dataframe as dd
  people = [[random.randint(1,3), random.randint(1,3), random.randint(1,3)] for i in range(1000)]
  ddf = dd.from_pandas(pd.DataFrame.from_records(people, columns=["first name", "last name", "cars"]), npartitions=1)
  </code></pre>
  
  <p>Now my mission is to group people by first and last name (e.g all the people with same first name &amp; first last name) and than I need to get a new dask data frame which will contain how many cars each group had.</p>
  
  <p>Assume that the apply function can return either a series of lists of tuples e.g [(name,name,cars count),(name,name,cars count)] or a data frame with the same columns - name, name, car count.</p>
  
  <p>Yes, I know that particular use case can be solved in another way, but please trust me, my use case is more complex. But i can not share the data and can not generate any similar data. so let's use a dummy data :-)</p>
  
  <p>The challenge is to connect all the results of the apply into a single dask data frame (pandas data frame will be a problem here, data will not fit in memory - so transitions via a pandas data frame will be a problem)</p>