# How to use a function to retrieve a single row of data from Parquet

**URL:** <https://discourse.julialang.org/t/how-to-use-a-function-to-retrieve-a-single-row-of-data-from-parquet/57356>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 17, 2021, 3:18am UTC](https://discourse.julialang.org/t/how-to-use-a-function-to-retrieve-a-single-row-of-data-from-parquet/57356 "2021-03-17T03:18:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![oo92](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oo92/32/22963_2.png) [@oo92](https://discourse.julialang.org/u/oo92)\
**Post date:** [March 17, 2021, 3:19am UTC](https://discourse.julialang.org/t/how-to-use-a-function-to-retrieve-a-single-row-of-data-from-parquet/57356/1 "2021-03-17T03:19:00Z")

</div>

Hi. I have a dataframe like this:

 ![data](https://global.discourse-cdn.com/julialang/original/3X/d/4/d471165f4d2492081ec9cad82ba9debadb83fc65.png)

I want to be able to get the numerical data for a single row, say, “Algeria”. This is the function that I wrote for that.

```julia
function get_country_data(country)
	data_by_country |>
		data -> filter(:country => val -> val == country, data) |>
		data -> data[1, 2:end] |>
		data -> convert(Vector, data)
end;

```

I try to call the function like this:

```julia
get_country_data("Algeria")

```

But this is the error I’m getting:

```julia
ArgumentError: column name :country not found in the data frame

lookupname@index.jl:288[inlined]
getindex@index.jl:297[inlined]
#filter#79@abstractdataframe.jl:1002[inlined]
filter@abstractdataframe.jl:1002[inlined]
(::Main.workspace79.var"#1#5"{String})(::DataFrames.DataFrame)@Other: 3
|>(::DataFrames.DataFrame, ::Main.workspace79.var"#1#5"{String})@operators.jl:834
get_country_data(::String)@Other: 2
top-level scope@Local: 1[inlined]

```

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [March 17, 2021, 4:33am UTC](https://discourse.julialang.org/t/how-to-use-a-function-to-retrieve-a-single-row-of-data-from-parquet/57356/2 "2021-03-17T04:33:38Z")

</div>

It’s called `Country/Region` in your screenshot.

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [March 17, 2021, 5:00am UTC](https://discourse.julialang.org/t/how-to-use-a-function-to-retrieve-a-single-row-of-data-from-parquet/57356/3 "2021-03-17T05:00:08Z")

</div>

I suspect this would help you [Best Julia Data Manipulation packages combo 2020-09 - YouTube](https://www.youtube.com/watch?v=q_P2H_ZXVxI&t=2s)

I don’t think your code works at all looking at the data.

---

<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:** [March 17, 2021, 11:02am UTC](https://discourse.julialang.org/t/how-to-use-a-function-to-retrieve-a-single-row-of-data-from-parquet/57356/4 "2021-03-17T11:02:51Z")

</div>

It looks like this post suffers from the same confusion as your other post about converting from CSV to Parquet: what you are working with after reading in from CSV or Parquet is (most likely) a `DataFrame` object, which is the same irrespective of how it was constructed (i.e. read from a CSV file, Parquet file, Arrow file,… or indeed constructed “manually” like `DataFrame(col1 = rand(10), col2 = rand(10))`)

So your title “… retrieve a single row of data from Parquet” is a bit misleading - you are probably asking for a way to select a row from a `DataFrame` object (unless you are reading your parquet data into some other tabular type, in which case please specify this).

This works by simple indexing like for a standard two-dimensional Julia Array:

```julia
df[df."Country/Region" .== "Algeria", :]

```

will give you all rows for which the `Country/Region` column has the value `Algeria`, and all columns in that row.

I’d recomment you work through Bogumil’s excellent introduction to DataFrames here: [https://github.com/bkamins/Julia-DataFrames-Tutorial](https://github.com/bkamins/Julia-DataFrames-Tutorial) if you intend to work with them.
