# Error message when using DataFrame()

**URL:** <https://discourse.pumas.ai/t/error-message-when-using-dataframe/470>\
**Category:** Data read\
**Created:** [March 31, 2021, 3:30pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470 "2021-03-31T15:30:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ahmed.salem](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@ahmed.salem](https://discourse.pumas.ai/u/ahmed.salem)\
**Post date:** [March 31, 2021, 3:30pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/1 "2021-03-31T15:30:13Z")

</div>

Hi,  
I am trying to convert the simulation object output to a data frame using DataFrame() function but I am receiving the following error  
**ERROR: DimensionMismatch(“array could not be broadcast to match destination”)**  
I would like to know how to interpret this error

Thanks

---

<div class="post-metadata">

**Author:** ![mohamed82008](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/mohamed82008/32/127_2.png) [@mohamed82008](https://discourse.pumas.ai/u/mohamed82008)\
**Post date:** [April 1, 2021, 3:36am UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/2 "2021-04-01T03:36:52Z")

</div>

Hi Ahmed. If you have a minimal example that gives the error, we will be able to help you better.

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [April 1, 2021, 3:43pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/3 "2021-04-01T15:43:55Z")

</div>

Do you have time varying covariates, @ahmed.salem ?

---

<div class="post-metadata">

**Author:** ![ahmed.salem](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@ahmed.salem](https://discourse.pumas.ai/u/ahmed.salem)\
**Post date:** [April 1, 2021, 5:40pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/4 "2021-04-01T17:40:29Z")

</div>

Yes I have a time varying covariate. It seems that there was a bug when there is time varying covariate (from a previous post) and It should have been resolved in the next release of Pumas

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [April 5, 2022, 12:33pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/5 "2022-04-05T12:33:39Z")

</div>

I have a PK dataset with the standard dosing and observations records such as: id, time, amt, conc, evid, cmt. My amt column is in mg. I am trying to create another amt column called amt\_in\_ug = amt \* 1000. However, I get errors most likely because several amt rows are missing. how to handle such mathematical operations with columns with missing rows? This is a very frequent data formatting maneuver and unfortunately I could not find any info when I searched in google for julia code. The first link was to this [Missing Values · The Julia Language](https://docs.julialang.org/en/v1/manual/missing/) but I could not find any answer to my a question similar to mine. Thank you.  
Bob

---

<div class="post-metadata">

**Author:** ![vijay](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pumas.ai/vijay/32/96_2.png) [@vijay](https://discourse.pumas.ai/u/vijay)\
**Post date:** [April 5, 2022, 12:40pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/6 "2022-04-05T12:40:02Z")

</div>

> **[⚡ Pluto.jl ⚡](https://tutorials.pumas.ai/html/DataWranglingInJulia/09-missing_data.html)**
>
> Pluto.jl notebooks

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [April 5, 2022, 12:58pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/7 "2022-04-05T12:58:20Z")

</div>

This looks like a new syntax from what I learned from the tutorials?  
@rtransform pkdata @passmissing :amt\_Bool=convert(Bool, :amt)  
pkdata[!,:amt\_in\_ug] = pkdata.amt\_Bool .\* 1000

Is this how I perform my operation?  
Bob

---

<div class="post-metadata">

**Author:** ![ahmed.salem](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@ahmed.salem](https://discourse.pumas.ai/u/ahmed.salem)\
**Post date:** [April 5, 2022, 4:04pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/8 "2022-04-05T16:04:28Z")

</div>

I am not sure what is your data formatting, syntax you use and the error you get but assuming the following example you should get the new column like this:

```auto
df= DataFrame(id = repeat([1],inner= 5),amt = [100,missing,missing,missing,missing])
df[!,:amt_2] = @. df[!,:AMT]*100

```

---

<div class="post-metadata">

**Author:** ![bobbrown](https://avatars.discourse-cdn.com/v4/letter/b/c2a13f/32.png) [@bobbrown](https://discourse.pumas.ai/u/bobbrown)\
**Post date:** [April 5, 2022, 4:29pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/9 "2022-04-05T16:29:33Z")

</div>

@ahmed.salem thank you. I think I had a problem with ‘.’ (forgot to include).

However, the syntax that is provided in the tutorial and the above are different. One uses @transform etc; the above uses a format I am more used to. However, I did not realize I had to use ‘@.’. I have only used ‘@’ in the derived block after an ‘=’. Is there a preferred format?  
Bob

---

<div class="post-metadata">

**Author:** ![ahmed.salem](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@ahmed.salem](https://discourse.pumas.ai/u/ahmed.salem)\
**Post date:** [April 5, 2022, 5:43pm UTC](https://discourse.pumas.ai/t/error-message-when-using-dataframe/470/10 "2022-04-05T17:43:16Z")

</div>

So in above example you do not even need to do broadcasting which is adding “@.” like example below

```auto
df= DataFrame(id = repeat([1],5),amt = [100,missing,missing,missing,missing],factor = repeat([1000],5))
df[!,:amt_2] = df[!,:amt]*100

```

But in case you want to multiply by another column (for example here I added 100 in a column called factor), you need to do broadcasting in one of two ways like the following

```auto
df= DataFrame(id = repeat([1],5),amt = [100,missing,missing,missing,missing],factor = repeat([1000],5))
df[!,:amt_2] = @. df[!,:amt]*df[!,:factor] #method 1
df[!,:amt_2] .= df[!,:amt].*df[!,:factor] # method 2

```

My understanding is that adding “@.” will override adding “.” before every operation. Hope it is clearer
