Skip to content

michikawa07/EvalDataFrames.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EvalDataFrames Build Status Stable Dev Build Status

Unitfulパッケージによって提供される単位付き数値をDataFrame+CSVで保存後に読み込みすることを念頭に作成した.

DataFrameの指定したカラムの文字列をjuliaの構文で評価する.

Quick Start

julia> using EvalDataFrames

julia> df = DataFrame(A = ["1+2","sqrt(2)"])
2×1 DataFrame
 Row │ A       
     │ String  
─────┼─────────
   11+2
   2sqrt(2)

julia> df |> eval!
2×1 DataFrame
 Row │ A       
     │ Real    
─────┼─────────
   13
   21.41421
julia> df = DataFrame(
			A = ["1+2", "1(N/s*kg^2)"],
			B = [:(1+2), :(1u"N")],
			C = ["1+2", "1u\"N\""],
			D = ["[1+2][1]", "[sqrt(1m)]"],
       )
2×4 DataFrame
 Row │ A            B         C       D
     │ String       Expr      String  String     
─────┼───────────────────────────────────────────
   11+2          1 + 2     1+2     [1+2][1]
   21(N/s*kg^2)  1 * u"N"  1u"N"   [sqrt(1m)]

julia> eval!(df,:A, parser=uparse)
2×4 DataFrame
 Row │ A            B         C       D
     │ Number       Expr      String  String     
─────┼───────────────────────────────────────────
   13  1 + 2     1+2     [1+2][1]
   21 kg² N s⁻¹  1 * u"N"  1u"N"   [sqrt(1m)]

julia> eval!(df,:B, :C)
2×4 DataFrame
 Row │ A            B       C       D
     │ Number       Number  Number  String     
─────┼─────────────────────────────────────────
   13       3       3  [1+2][1]
   21 kg² N s⁻¹     1 N     1 N  [sqrt(1m)]	

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages