# Add a row to dataframe, fill it with integers and sum the values

**URL:** https://discourse.julialang.org/t/add-a-row-to-dataframe-fill-it-with-integers-and-sum-the-values/96774
**Category:** New to Julia
**Created:** [March 29, 2023, 12:37pm UTC](https://discourse.julialang.org/t/add-a-row-to-dataframe-fill-it-with-integers-and-sum-the-values/96774 "2023-03-29T12:37:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![CvR](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@CvR](https://discourse.julialang.org/u/CvR)
#### Post date: [March 29, 2023, 12:37pm UTC](https://discourse.julialang.org/t/add-a-row-to-dataframe-fill-it-with-integers-and-sum-the-values/96774/1 "2023-03-29T12:37:58Z")

</div>

I’m writing a script where a user can add a row to a dataframe (df2) and fill in some integer values (1 through 9). What I have is this:

```julia
n_rows = nrow(df2)
println("Give sores for", n_rows, " rows: ")
scores_temp = readline()
scores = split(scores_temp, " ")
parse.(Int64, scores)
for i in 1:length(scores)
      scores[i] = scores[i]
end
df2[:, "Score"].= scores
println(df2)
tot_score = sum(df2[!, :Score]) # this doesn't work!
println(tot_score)

```

All goes wel, but when summing the added column (:Score) I get an error:

```julia
ERROR: MethodError: no method matching +(::SubString{String}, ::SubString{String})

```

I tried different summing methods. But I can’t find the mistake I make.

---

<div class="post-metadata">

### Author: ![tbeason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbeason/32/15898_2.png) [@tbeason](https://discourse.julialang.org/u/tbeason)
#### Post date: [March 29, 2023, 12:44pm UTC](https://discourse.julialang.org/t/add-a-row-to-dataframe-fill-it-with-integers-and-sum-the-values/96774/2 "2023-03-29T12:44:26Z")

</div>

> [@CvR](#):
>
> ```julia
> parse.(Int64, scores)
> for i in 1:length(scores)
> scores[i] = scores[i]
> end
> df2[:, "Score"].= scores
> 
> ```

None of this really does anything. You just want

```julia
df2[:, "Score"] = parse.(Int64, scores)

```

except maybe you want more logic there like `tryparse` + something in case the input is not integer.

---

<div class="post-metadata">

### Author: ![CvR](https://avatars.discourse-cdn.com/v4/letter/c/4bbf92/32.png) [@CvR](https://discourse.julialang.org/u/CvR)
#### Post date: [March 29, 2023, 12:57pm UTC](https://discourse.julialang.org/t/add-a-row-to-dataframe-fill-it-with-integers-and-sum-the-values/96774/3 "2023-03-29T12:57:38Z")

</div>

Thnx tbeason, that works very well! Less is better and still learning :smile
