# Cleanest way to convert DataFrame row into a Vector?

**URL:** <https://discourse.julialang.org/t/cleanest-way-to-convert-dataframe-row-into-a-vector/5531>\
**Category:** Data\
**Tags:** question, dataframes, vector\
**Created:** [August 24, 2017, 1:02am UTC](https://discourse.julialang.org/t/cleanest-way-to-convert-dataframe-row-into-a-vector/5531 "2017-08-24T01:02:57Z")\
**Posts on this page:** 1\
**Page:** 2

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [February 24, 2023, 12:30pm UTC](https://discourse.julialang.org/t/cleanest-way-to-convert-dataframe-row-into-a-vector/5531/22 "2023-02-24T12:30:59Z")

</div>

I suspect that was an issue with the measurement rather than a true difference. @tecosaur how did you benchmark? Here’s what I get with Julia 1.9-beta4:

```julia
using DataFrames
using BenchmarkTools

df = DataFrame(rand(100,1000), :auto)

f(df, row) = [df[row,i] for i in 1:ncol(df)]
g(df, row) = collect(Base.Generator(i -> df[row, i], 1:ncol(df)))

julia> @btime f($df, 1);
  31.522 μs (1003 allocations: 23.62 KiB)

julia> @btime g($df, 1);
  31.086 μs (1003 allocations: 23.62 KiB)

```

[Previous page](https://discourse.julialang.org/t/cleanest-way-to-convert-dataframe-row-into-a-vector/5531.md?page=1)
