朱莉娅将数据从数据范围设置为JSON
相关文章: dataframes到数据库表
确实,我的计划是从DataFrame到JSON的数据。我正在尝试使用Genie Frame Work和genie.json,示例数据如下,
Row │ id name address age sex
│ Int64 String String? String? String?
─────┼───────────────────────────────────────────
1 │ 1 Ono Kyoto 60 m
2 │ 2 Serena PA 38 F
3 │ 3 Edita Slovakia 32 F
并且将这些数据包装成数据框架,然后
json( Dict( "alldata" => res ))
按列列出JSON数据。
(a):{“ alldata”:{“ columns”:[[1,2,3],[“ ono”,“ serana”,“ edita”],[“ kyoto”,“ pa”,“ slovakia”] ,[“ 60”,“ 38”,“ 32”],[“ M”,“ F”,“ F”]}}}}}}}}}}}}}}
,当然,我想将每一行像这样
(b):{ “ alldata”:{“列”:[[1,“ ono”,“ kyoto”,“ 60”,“ M”],[2,“ Serana”,“ Pa”,“ 38”,“ F”], [3,“ edita”,“斯洛伐克”,“ 32”,“ f”]}}}}}}}}}}}}}}}}}}}}}}},
然后在序列化后使用JSON3软件包获得了答案。该程序是有道理的,但是我想知道是否有任何想法都不使用序列化处理。 理想过程是从数据范围到JSON的直接传递到实现(b)JSON表单数据。
通过序列化
oDf::DataFrame = SearchLight.query( sSelect )
if !isempty(oDf)
for oRow in eachrow(oDf)
_iid::Int = oRow.id
_sname::String = oRow.name
・
・
push!( aTmp["alldata"], Dict("columns"=>[_iid,_sname,_saddress,_sage,_ssex]))
end
aTmp["data_ready"] = 1
end
sRetJ = JSON3.write(aTmp)
我查看了dataframes.jl,但没有找到解决方案,但本书也许有它,但是还没有。 谢谢任何进步。
related post: DataFrames to Database tables
Indeed, my plan is data passing from DataFrame to json. I am trying to use Genie frame work and Genie.json, the sample data is as following,
Row │ id name address age sex
│ Int64 String String? String? String?
─────┼───────────────────────────────────────────
1 │ 1 Ono Kyoto 60 m
2 │ 2 Serena PA 38 F
3 │ 3 Edita Slovakia 32 F
and this data packed to res as DataFrames, then
json( Dict( "alldata" => res ))
the json data is lined order by columns.
(A):{"alldata":{"columns":[[1,2,3], ["Ono","Serana","Edita"],["Kyoto","PA","Slovakia"],["60","38","32"],["m","f","f"]]}}
But, of course, I would like to get each row like this
(B):{"alldata":{"columns":[[1,"Ono","Kyoto","60","m"],[2,"Serana","PA","38","f"],[3,"Edita","Slovakia","32","f"]]}}
I posted the same question on Genie community then got answer using JSON3 package after serialization. That procedure made sense, however I wonder are there any ideas alike do not use serialize processing. The ideal process is direct pass from Dataframes to json to realize (B) json form data.
To json by serializing
oDf::DataFrame = SearchLight.query( sSelect )
if !isempty(oDf)
for oRow in eachrow(oDf)
_iid::Int = oRow.id
_sname::String = oRow.name
・
・
push!( aTmp["alldata"], Dict("columns"=>[_iid,_sname,_saddress,_sage,_ssex]))
end
aTmp["data_ready"] = 1
end
sRetJ = JSON3.write(aTmp)
I looked at DataFrames.jl but did not find the solution, maybe the book has it, but not yet.
Thanks any advances.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您想要以下内容:(
但是,奇怪的是,您想调用此
“列”
,而这些是数据的行),如果您要保留可以执行的列名称:
I assume you want the following:
(however, it is strange that you want to call this
"columns"
while these are rows of your data)If you want to retain column names you can do: