# How to coerce types from data loaded via ExcelFiles.jl

**URL:** <https://discourse.julialang.org/t/how-to-coerce-types-from-data-loaded-via-excelfiles-jl/44161>\
**Category:** General Usage\
**Created:** [August 3, 2020, 2:57am UTC](https://discourse.julialang.org/t/how-to-coerce-types-from-data-loaded-via-excelfiles-jl/44161 "2020-08-03T02:57:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fnbillimoria](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fnbillimoria/32/16518_2.png) [@fnbillimoria](https://discourse.julialang.org/u/fnbillimoria)\
**Post date:** [August 3, 2020, 2:57am UTC](https://discourse.julialang.org/t/how-to-coerce-types-from-data-loaded-via-excelfiles-jl/44161/1 "2020-08-03T02:57:40Z")

</div>

Hi, I am loading a sheet from an excel file using ExcelFiles.jl. I wish to convert the types for some of the columns that are loaded as a dataframe. Some of the columns load as a float, and I wish to coerce them to an int. I have prior knowledge that these columns will always not have any decimal digits, so I am not worried about type mismatches. I have pasted a screenshot of the excel file structure. The second row sets out the columns i would like to coerce. I attempted using the code below, but this appears to have no effect. Any assistance greatly appreciated.

![Capture](https://global.discourse-cdn.com/julialang/original/3X/d/d/dd727d8e6d8ffaa3cb54b9629c6921e9dffee1d4.jpeg)

```julia
using ExcelFiles, DataFrames
data1 = "C:/Users/fbillimoria/OneDrive - Nexus365/DPhil/Scripts/Powermodel/data/file.xlsx"
df = (DataFrame(load(data1,"info")))
df_lab = DataFrame(load(data1,"info",nrows=2))
df_data = DataFrame(load(data1,"info",skipstartrows=2))

for i in names(df_lab)
    if df_lab[i][1] == "int"
        df_data[i] = convert(Int64,df_data[i])
    end
end

```

---

<div class="post-metadata">

**Author:** ![bernhard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bernhard/32/2619_2.png) [@bernhard](https://discourse.julialang.org/u/bernhard)\
**Post date:** [August 3, 2020, 11:05am UTC](https://discourse.julialang.org/t/how-to-coerce-types-from-data-loaded-via-excelfiles-jl/44161/2 "2020-08-03T11:05:32Z")

</div>

What is not clear from your question: Is your code (to convert) running or not?

If not, maybe try this line instead  
`df_data[!,i] = convert(Vector{Int64},df_data[!,i])`
