# Query - column names with spaces

**URL:** https://discourse.julialang.org/t/query-column-names-with-spaces/56232
**Category:** General Usage
**Tags:** query, dataframes
**Created:** [March 1, 2021, 5:31am UTC](https://discourse.julialang.org/t/query-column-names-with-spaces/56232 "2021-03-01T05:31:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![statspy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/statspy/32/26630_2.png) [@statspy](https://discourse.julialang.org/u/statspy)
#### Post date: [March 1, 2021, 5:31am UTC](https://discourse.julialang.org/t/query-column-names-with-spaces/56232/1 "2021-03-01T05:31:26Z")

</div>

I have this df: `d = DataFrame(Symbol("Full Name") => ["Mike","Paul","Andres"], Symbol("Age") => 10:12)` so far so good. Now i want to do this Query:

```julia
using Query
@from i in d begin
@where i.Age == 11
@select {i."Full Name", i.Age}
@collect DataFrame
end

```

But it returns an error. I think its because that “Full Name” field because it goes fine if the field name is just “Name”. How can i fix it?

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [March 1, 2021, 5:37am UTC](https://discourse.julialang.org/t/query-column-names-with-spaces/56232/2 "2021-03-01T05:37:35Z")

</div>

> [@statspy](#):
>
> `@select {i."Full Name", i.Age}`

does this work:

```julia
@select {getfield(i, Symbol("Full Name")), i.Age}

```

---

<div class="post-metadata">

### Author: ![statspy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/statspy/32/26630_2.png) [@statspy](https://discourse.julialang.org/u/statspy)
#### Post date: [March 1, 2021, 5:53am UTC](https://discourse.julialang.org/t/query-column-names-with-spaces/56232/3 "2021-03-01T05:53:55Z")

</div>

> [@jling](#):
>
> does this work:
> 
> ```julia
> @select {getfield(i, Symbol("Full Name")), i.Age}
> 
> ```

Nope.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [March 1, 2021, 5:57am UTC](https://discourse.julialang.org/t/query-column-names-with-spaces/56232/4 "2021-03-01T05:57:43Z")

</div>

ok then the macros in Query may need a feature addition to support `d."Full Name"`

---

<div class="post-metadata">

### Author: ![statspy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/statspy/32/26630_2.png) [@statspy](https://discourse.julialang.org/u/statspy)
#### Post date: [March 1, 2021, 6:01am UTC](https://discourse.julialang.org/t/query-column-names-with-spaces/56232/5 "2021-03-01T06:01:55Z")

</div>

yaeah…this seems to be so simple and yet i cant do it…if the column name is just “Name” or “Full\_Name” then i can get it done. that space between Full and Name is the problem…so frustrating…

---

<div class="post-metadata">

### Author: ![Fred](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fred/32/14175_2.png) [@Fred](https://discourse.julialang.org/u/Fred)
#### Post date: [April 6, 2023, 8:11am UTC](https://discourse.julialang.org/t/query-column-names-with-spaces/56232/6 "2023-04-06T08:11:15Z")

</div>

@statspy , I had exactly the same problem today. I use this code to remove the spaces in the colnames of the dataframe “df”

```julia
# remove spaces in colnames
oldNames = names(df)
newNames = Vector{String}(undef, length(oldNames))
for (i, name) in enumerate(oldNames) 
    new = replace(name, " " => "") 
    newNames[i] = new
end
rename!(df, newNames)

```
