title: Explanding GeoPandas Multipolygon Dataframe To One Poly Per Line
body: <p>This question is similar to another one out there but none of the solutions worked for me. Note I have included several attempts at those solutions and results. If another library will achieve this I am open to it. </p>
  
  <p>I am trying to expand a GeoJson file using GeoPandas where it contains multiple multi polygons.  </p>
  
  <p><strong>Current geodataframe (3 Rows)</strong> </p>
  
  <pre><code>fill    fill-opacity    stroke  stroke-opacity  stroke-width    title   geometry
  0   #9bf1e2 0.3 #9bf1e2 1   1   Hail Possible   (POLYGON ((-80.69500140880155 22.2885709067316...
  1   #08c1e6 0.3 #08c1e6 1   1   Severe Hail (POLYGON ((-103.4850007575523 29.2010260633722...
  2   #682aba 0.3 #682aba 1   1   Damaging Hail   (POLYGON ((-104.2750007349772 32.2629245180204...`
  </code></pre>
  
  <p><strong>Desired geodataframe (200+ Rows)</strong> </p>
  
  <pre><code>fill    fill-opacity    stroke  stroke-opacity  stroke-width    title   geometry
  0   #9bf1e2 0.3 #9bf1e2 1   1   Hail Possible   (POLYGON ((-80.69500140880155 22.2885709067316...
  1   #9bf1e2 0.3 #9bf1e2 1   1   Hail Possible   (POLYGON ((-102.8150007766983 28.2180513479277...
  2   #9bf1e2 0.3 #9bf1e2 1   1   Hail Possible   (POLYGON ((-103.4850007575523 29.0940821135748...
  3   #9bf1e2 0.3 #9bf1e2 1   1   Hail Possible   (POLYGON ((-103.5650007552662 30.9947420843694...
  4   #9bf1e2 0.3 #9bf1e2 1   1   Hail Possible   (POLYGON ((-103.6150007538374 31.0173836504729...
  </code></pre>
  
  <p>Sample File of geojson file being used: <a href="https://drive.google.com/file/d/1m6cMR4jF3QWp07e23sIdb0UF9xLD062s/view?usp=sharing" rel="noreferrer">https://drive.google.com/file/d/1m6cMR4jF3QWp07e23sIdb0UF9xLD062s/view?usp=sharing</a></p>
  
  <p><strong>What I've Tried with no success:</strong></p>
  
  <pre><code>df3.set_index(['title'])['geometry'].apply(pd.Series).stack().reset_index()
  </code></pre>
  
  <p>(Returns original unchanged gdf) </p>
  
  <pre><code>def cartesian(x): 
      return np.vstack(np.array([np.array(np.meshgrid(*i)).T.reshape(-1,7) for i in x.values]))
  ndf = pd.DataFrame(cartesian(df3),columns=df3.columns)
  </code></pre>
  
  <p>(Returns original unchanged gdf) </p>
  
  <pre><code>import geopandas as gpd
  from shapely.geometry.polygon import Polygon
  from shapely.geometry.multipolygon import MultiPolygon
  
  def explode(indata):
      indf = gpd.GeoDataFrame.from_file(indata)
      outdf = gpd.GeoDataFrame(columns=indf.columns)
      for idx, row in indf.iterrows():
          if type(row.geometry) == Polygon:
              outdf = outdf.append(row,ignore_index=True)
          if type(row.geometry) == MultiPolygon:
              multdf = gpd.GeoDataFrame(columns=indf.columns)
              recs = len(row.geometry)
              multdf = multdf.append([row]*recs,ignore_index=True)
              for geom in range(recs):
                  multdf.loc[geom,'geometry'] = row.geometry[geom]
              outdf = outdf.append(multdf,ignore_index=True)
      return outdf
  
  explode(GEOJSONFILE)
  </code></pre>
  
  <p>(Returns original unchanged gdf) </p>
  
  <p>This is my first question on here so if any additional info or details are needed please let me know. </p>
  
  <p>UPDATE:  Found out the issue with the explode() function was due to a formatting issue on the file where the geometry was essentially a multi-polygon of multi-polygon causing a loop of only the first multi-polygon.  The explode function works. </p>