0
votes

For instance if I create a dataframe as follows

X = rand(10, 10)
X = convert(DataFrame, X)

How do I show values > 0.5

Thanks in advance.

1
Not quite, doesn't work with Dataframes. X[X .> 0.5] would produce an errorVladimir
Can you please be more precise what you want to get? If you want to treat the whole DataFrame as homogeneous object you can always convert it back to matrix by writing Matrix(df) and work on it then.Bogumił Kamiński
With your code you have a table with 10 rows and 10 columns. You can then select individual rows, but you have to choose based on what. Is > 0.5 in all columns? In at least one? On the first column?Antonello
What kind of result are you expecting? A DataFrame? I wonder if an IndexedTables is not a better data structure for that purpose.scls
Query.jl might also be useful here.carstenbauer

1 Answers

0
votes

We should use the most practical tool to accomplish what we want. I don't think a DataFrame is of much use here, so I suggest you convert it back to a numeric array. Of course, you're not planning to use this on an array of random numbers.

using DataFrames

X = rand(10, 10)
X = convert(DataFrame, X)

X = convert(Matrix, X)
ind = X .> 0.5
vals = X[ind] 

ind
vals

#=
Main> ind
10×10 BitArray{2}:
 false  false   true   true   true   true  false  false   true   true
  true  false  false   true  false  false   true   true  false  false
  true   true  false   true  false   true   true  false  false   true
 false   true  false   true   true  false  false   true   true  false
  true  false   true   true   true   true  false   true   true   true
  true  false  false   true   true   true   true   true   true   true
 false  false   true  false  false   true   true  false  false   true
  true   true  false   true   true  false   true   true  false  false
 false  false  false   true   true   true  false   true  false  false
  true   true   true  false   true   true   true  false  false  false

Main> vals
57-element Array{Float64,1}:
 0.52951
 0.743512
 0.576547
 0.697369
 0.951203
 0.656204
 ⋮
 0.803584
 0.714883
 0.730805
 0.529729
 0.845263 
 =#

You can check the position of the subset in the original array in ind and the actual values in vals