Stream: helpdesk (published)

Topic: Rounding Entire Columns


view this post on Zulip QuBit (Mar 04 2021 at 10:47):

Hello:

I have a two columns in a dataframe whose values I would
like to round. I am using;

select(FINAL, round.(FINAL[!, 8:9], digits=0))

I COULD split the dataframe and then use the hcat function
but I was wondering if there is a one-line approach?

Thank you,

view this post on Zulip QuBit (Mar 04 2021 at 12:05):

qu bit said:

Hello:

I have a two columns in a dataframe whose values I would
like to round. I am using;

select(FINAL, round.(FINAL[!, 8:9], digits=0))

I COULD split the dataframe and then use the hcat function
but I was wondering if there is a one-line approach?

Thank you,

Update,

I am experimenting with using Query.jl
where:

begin
FINAL = @from i in DF begin
                 @select i
                 @orderby descending(i.2)
                 @collect DataFrame
                 end
FINAL = @from i in DF begin
                 @select round.(i[!,8:9], digits=0)
                 @collect DataFrame
                 end
end

Any suggestions about this?

view this post on Zulip QuBit (Mar 05 2021 at 10:45):

qu bit said:

qu bit said:

Hello:

I have a two columns in a dataframe whose values I would
like to round. I am using;

select(FINAL, round.(FINAL[!, 8:9], digits=0))

I COULD split the dataframe and then use the hcat function
but I was wondering if there is a one-line approach?

Thank you,

Update,

I am experimenting with using Query.jl
where:

begin
FINAL = @from i in DF begin
                 @select i
                 @orderby descending(i.2)
                 @collect DataFrame
                 end
FINAL = @from i in DF begin
                 @select round.(i[!,8:9], digits=0)
                 @collect DataFrame
                 end
end

Any suggestions about this?

A simple way to approach this is to use:

SinkDF.A = round.(SourceSF.A, digits = N)

After the first argument you can apply
different arithmetic operators to save
a column calculation step.


Last updated: Nov 06 2024 at 04:40 UTC