- Solve real problems with our hands-on interface
- Progress from basic puts and calls to advanced strategies

Posted April 20, 2022 at 8:30 pm
Learn how to create new dataframes with Part I.
As discussed in my previous post, basic arithmetic operations can be performed on individual columns.
# Subtraction
df_2.a - df_2.bsubtraction.jl hosted with ❤ by GitHub
10-element Vector{Float64}:
-0.5474996670806442
0.5174063588946236
-0.564150142575268
0.12873854328766576
0.2741519215981265
0.20241852864291987
0.09324017568958975
-0.41716724316286524
0.2693306887583933
-0.5967498723478988You’ll have to use the “.” operator for element-wise division.
df_2.["a"] ./ df_2["b"] elementwise operation.jl hosted with ❤ by GitHub
10-element Vector{Float64}:
0.06754620232737023
3.013387340201863
0.4169119702423886
1.2293455286486041
1.4462537614868343
8.482279426917298
1.1103752688515762
0.21238611891693882
3.1244976300403002
0.38733760512833965r” is a regex search string. Here, any column with a string “work” will be selected and moved to the first place. You can write the full column name as well.
## Method to rearrange columns in a dataframe
select!(df_1, r"work", :)rearranging columns.jl hosted with ❤ by GitHub
| work experience | name | team |
|---|---|---|
| Int64 | String | String |
| 15 | Vivek | EPAT |
| 8 | Viraj | Marketing |
| 7 | Rohan | Sales |
| 10 | Ishan | Quantra |
Here we add another column, “c”, to the dataframe df_2.
df_2.c = rand(10)
df_2adding new column.jl hosted with ❤ by GitHub
| a | b | c |
|---|---|---|
| Float64 | Float64 | Float64 |
| 0.845011 | 0.720306 | 0.962749 |
| 0.647665 | 0.0409036 | 0.10846 |
| 0.427267 | 0.221369 | 0.197592 |
| 0.413642 | 0.374832 | 0.967406 |
| 0.477994 | 0.118461 | 0.0233091 |
| 0.0849006 | 0.157679 | 0.936764 |
| 0.0477405 | 0.845332 | 0.296003 |
| 0.518909 | 0.159305 | 0.514714 |
| 0.93499 | 0.259579 | 0.620951 |
| 0.60034 | 0.115911 | 0.0224133 |
Matrix(df_2)dataframe to matrix.jl hosted with ❤ by GitHub
10×3 Matrix{Float64}:
0.0396604 0.58716 0.741712
0.774389 0.256983 0.429361
0.403371 0.967521 0.989583
0.690069 0.56133 0.50599
0.888493 0.614341 0.152574
0.229472 0.0270531 0.932589
0.937996 0.844756 0.0745573
0.112492 0.52966 0.712178
0.396105 0.126774 0.397762
0.377277 0.974027 0.685073Visit QuantInsti to read the full article: https://blog.quantinsti.com/data-manipulation-visualization-using-julia/.
Information posted on IBKR Campus that is provided by third-parties does NOT constitute a recommendation that you should contract for the services of that third party. Third-party participants who contribute to IBKR Campus are independent of Interactive Brokers and Interactive Brokers does not make any representations or warranties concerning the services offered, their past or future performance, or the accuracy of the information provided by the third party. Past performance is no guarantee of future results.
This material is from QuantInsti and is being posted with its permission. The views expressed in this material are solely those of the author and/or QuantInsti and Interactive Brokers is not endorsing or recommending any investment or trading discussed in the material. This material is not and should not be construed as an offer to buy or sell any security. It should not be construed as research or investment advice or a recommendation to buy, sell or hold any security or commodity. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.
Join The Conversation
For specific platform feedback and suggestions, please submit it directly to our team using these instructions.
If you have an account-specific question or concern, please reach out to Client Services.
We encourage you to look through our FAQs before posting. Your question may already be covered!