# I do not understand this error: MethodError: no method matching iterate(::DataFrame)

**URL:** <https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530>\
**Category:** General Usage\
**Tags:** first-steps\
**Created:** [February 12, 2020, 5:10pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530 "2020-02-12T17:10:16Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aizzaac](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@Aizzaac](https://discourse.julialang.org/u/Aizzaac)\
**Post date:** [February 12, 2020, 5:10pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/1 "2020-02-12T17:10:17Z")

</div>

Hi

I want to know what a function is doing.  
The function can be found here:  
[[https://nbviewer.jupyter.org/github/JuliaX/iap2014/blob/master/GeoData.ipynb](https://nbviewer.jupyter.org/github/JuliaX/iap2014/blob/master/GeoData.ipynb)]

I have a dataframe which have columns with type “Shapefile”. So I guess it is not easy to share it here. But it looks like this:

![image](https://global.discourse-cdn.com/julialang/original/3X/a/3/a3677e0f66c1fb36e26099d422cf55c4a7cac50f.png)

THESE ARE THE LIBRARIES BEING USED

```
using Shapefile
using DataFrames
using Colors
using Compose
using Gadfly

```

THIS IS THE FUNCTION IN CODE

```
# Going from one kind of polygon to another
ESRI2Compose(poly::Shapefile.Polygon) = Compose.FormTree(Compose.Polygon([Compose.Point(point.x,point.y) for point in poly.points]))

```

THIS IS MY ATTEMPT

```
for row in df_x
    c = compose(c,compose(canvas(template),ESRI2Compose(row["x1"][1]),
    linewidth(0.05mm),stroke(color),fill(nothing)))
end

```

The goal is to apply that function to column “x1”

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 12, 2020, 5:17pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/2 "2020-02-12T17:17:40Z")

</div>

When iterating over rows you should use `for row in eachrow(df_x)`

---

<div class="post-metadata">

**Author:** ![Aizzaac](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@Aizzaac](https://discourse.julialang.org/u/Aizzaac)\
**Post date:** [February 12, 2020, 5:31pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/3 "2020-02-12T17:31:42Z")

</div>

Now I get this error:

![image](https://global.discourse-cdn.com/julialang/original/3X/d/e/de0cfbe674484f46b34716b8b542efbdc362f1d8.png)

Is it possible to use ONLY the ESRI2Compose function?  
Something like this:

```
for row in eachrow(df_x)
    c = ESRI2Compose(row["x1"][1])
end

```

But I get this error:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/f/0ff735a835edac55ae8ba66dd338c6aa85e0c292.png)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 12, 2020, 5:34pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/4 "2020-02-12T17:34:30Z")

</div>

Your example is not an MWE (see [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)), but it looks like you’re calling `compose(c, ...)` in your loop without first defining `c`.

It might be useful to have a look at the Julia language docs and maybe the documentation for the packages you’re using to get the hang of the basic usage, as step-by-step debugging via Discourse might be pretty time consuming…

---

<div class="post-metadata">

**Author:** ![Aizzaac](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@Aizzaac](https://discourse.julialang.org/u/Aizzaac)\
**Post date:** [February 12, 2020, 5:36pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/5 "2020-02-12T17:36:21Z")

</div>

But I cannot give a dataframe with type “Shapefile”

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 12, 2020, 5:39pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/6 "2020-02-12T17:39:12Z")

</div>

Not sure I understand - do you mean in terms of an MWE? There are many shapefiles available freely online, or you could equally just create a shapefile object manually in an MWE.

---

<div class="post-metadata">

**Author:** ![Aizzaac](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@Aizzaac](https://discourse.julialang.org/u/Aizzaac)\
**Post date:** [February 12, 2020, 5:55pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/7 "2020-02-12T17:55:42Z")

</div>

Well, if I write the dataframe i get a “string” type instead of a “shapefile”

```
df_mwe = DataFrame(MBR=["Rect(-80.1133, 43.5557, -79.9648, 43.7129)"])

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [February 13, 2020, 10:04am UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/8 "2020-02-13T10:04:46Z")

</div>

Currently none of the errors you encountered were related to actual shapefiles, so any DataFrame would have worked as an MWE. If you absolutely need a shapefile for the MWE you could either read it in from a publicly available URL or construct one using the constructor in the relevant package (I don’t work with shapefiles so wouldn’t know what this is, but above you are getting a `String` because `"a"` constructs a String, you would probably need something like `ShapeFile(-80.1133, 43.5557, -79.9648, 43.7129)` but the form of the constructor will depend on the package you’re using)

---

<div class="post-metadata">

**Author:** ![Aizzaac](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@Aizzaac](https://discourse.julialang.org/u/Aizzaac)\
**Post date:** [February 13, 2020, 3:25pm UTC](https://discourse.julialang.org/t/i-do-not-understand-this-error-methoderror-no-method-matching-iterate-dataframe/34530/9 "2020-02-13T15:25:09Z")

</div>

I thought you needed me to give a shapefile for the MWE. I already have my shapefile in a dataframe.  
Anyways I am currently using VegaLite. So I converted my shapefile to a topojson. The conversation is here: [https://discourse.julialang.org/t/how-to-make-vegalite-read-my-topojson-file/34546/10](https://discourse.julialang.org/t/how-to-make-vegalite-read-my-topojson-file/34546/10)
