Questions tagged [julia-dataframe]

51 questions
3
votes
1 answer

How to convert a Python pandas into a Julia DataFrame (using PyJulia) and back to Python Pandas

I want to use PyJulia to speed up some part of the code import numpy as np import julia import pandas as pd import random from julia import Base from julia import Main from julia import DataFrames n = 100000 randomlist = [] for i in range(0,n): …
ecjb
  • 5,169
  • 12
  • 43
  • 79
3
votes
2 answers

How to read record format json in Julia?

I am able to read a json file and convert into dataframe using below code. df = open(jsontable, "normal.json") |> DataFrame normal.json looks like below, {"col1":["thasin", "hello", "world"],"col2":[1,2,3],"col3":["abc", "def", "ghi"]} So final…
Mohamed Thasin ah
  • 10,754
  • 11
  • 52
  • 111
2
votes
1 answer

How to convert a Python pandas into a Julia DataFrame (using PyJulia) and back to Python Pandas with a function?

I want to pass a dataframe from python to a julia function, perform some calculations and then pass a dataframe back to python. From How to convert a Python pandas into a Julia DataFrame (using PyJulia) and back to Python Pandas by setting the…
Adri1
  • 23
  • 6
2
votes
1 answer

Format string numbers into Float64 in julia dataframe

I have a dataframe with a column (column 1) that looks like this. It's a bunch of numbers that are of type string. I would like to update "column 1" or create a new column "column 1 formatted" and the type to be either string or Float64 and to have…
hbrovell
  • 547
  • 6
  • 17
2
votes
1 answer

Combine grouped DF in Julia with Floats and Strings

I have a bunch of Grouped DataFrames gdf that I want to combine. I want to combine the GDF with the mean var1 which is a Float and the first element of var2 which is a String. I tried combine(gdf, :var1 .=> mean, :var2 .=> first(:var2)) But…
Moshi
  • 193
  • 6
2
votes
1 answer

How to balance a dataset from a countmap table

I have this dataset: text sentiment randomstring positive randomstring negative randomstring netrual random mixed Then if I run a countmap i have: "mixed" -> 600 "positive" -> 2000 "negative" ->…
math_guy_shy
  • 161
  • 6
2
votes
1 answer

How to calculate mean of values per unique class

I have a dataframe: sex age f 10 m 12 m 11 m 17 f 13 f 12 I 8 Want I want to calculate the mean of age per sex: f=> mean age = (10+13+12) /3 m=> mean age = (12+11+17) /3 I=> mean age = 8 I am trying something like…
Katty_one
  • 351
  • 1
  • 8
2
votes
1 answer

Stratified Sampling of a DataFrame

Given a dataframe with columns "a", "b", and "value", I'd like to sample N rows from each pair of ("a", "b"). In python pandas, this is easy to do with the following syntax: import pandas as pd df.groupby(["a", "b"]).sample(n=10) In Julia, I found…
Shffl
  • 396
  • 3
  • 18
2
votes
1 answer

Strange dates in plotting graph in Julia

I get some strange result when I try plotting a DataFrame. When I plot the starting graph it works great. using DataFrames, XLSX, StatsPlots, Indicators df = DataFrame(XLSX.readtable("Demo-sv.xlsx", "Blad3")...) df[!, :Closeprice] .=…
hbrovell
  • 547
  • 6
  • 17
2
votes
1 answer

How to get a new column that depends of a subset of dataframe columns

My dataframe has 3 columns A, B and C and for each row only one of these columns contains a value. I want a MERGE column that contains the values from A or B or C using DataFrames df = DataFrame(NAME = ["a", "b", "c"], A = [1, missing, missing], B…
attdona
  • 17,196
  • 7
  • 49
  • 60
2
votes
1 answer

ArgumentError: No key column found Unstack Error?

I have a df like below, Sample Input: 4×2 DataFrame │ Row │ col1 │ col2 │ │ │ String │ Int64 │ ├─────┼────────┼───────┤ │ 1 │ l1 │ 1 │ │ 2 │ l2 │ 2 │ │ 3 │ l1 │ 3 │ │ 4 │ l2 │ 4 │ I want to transform…
Mohamed Thasin ah
  • 10,754
  • 11
  • 52
  • 111
2
votes
0 answers

How to insert a new row in julia at specific index

I am using julia 1.4, I have a df like below. I want to add a new row to an existing dataframe at specific index. I found this but it seems old. I am using DataFrame(insert!.(eachcol(df), index, value)) to insert a row. I feel it's over performing.…
Mohamed Thasin ah
  • 10,754
  • 11
  • 52
  • 111
1
vote
0 answers

Julia - Get variable names out of StatsModels.ModelMatrix, Replicate the mapping it does from DataFrame to Matrix

I have some data frame like the below and want do the regression expressed in the below formula on it. using GLM, StatsModels, Tables, DataFrames training = DataFrame(yy = [1,2,3,7,5,4,2,3], continuous = [5,5,6,6,7,8,8,9], categorical =…
Stuart
  • 1,322
  • 1
  • 13
  • 31
1
vote
1 answer

vcat DataFrame columns based on multiple columns in Julia

I have 3 DataFrames, each containing 3 columns: A, B, and C. using DataFrames common_data = Dict("A" => [1, 2, 3], "B" => [10, 20, 30]) df1 = DataFrame(merge(common_data, Dict("C" => [100, 200, 300]))) df2 = DataFrame(merge(common_data, Dict("C"…
PrinceZard
  • 25
  • 4
1
vote
2 answers

ERROR: MethodError: no method matching isless(::Vector{UnitRange{Int64}}, ::Int64)

I am new to Julia and I am struggling to compare the values stored in a vector with a integer (which is a threshold I want to use to determine if a certain condition is true or false). The actual values are stored as columns in a dataframe but the…
Manuel
  • 11
  • 1