gpt4 book ai didi

dataframe - 在 Julia 中绘制 DataFrame 的子集

转载 作者:行者123 更新时间:2023-12-04 07:47:57 25 4
gpt4 key购买 nike

我有来自光谱仪的数据,该光谱仪每 5 分钟左右测量一次,并将其放入 CSV 文件中。
第一列代表测量时间,接下来的两千列代表给定波长的光强度。
我想获得一天中频谱如何演变的 3D 表示,但到目前为止,我什至都在努力绘制给定时间的单个频谱。
我尝试了以下方法:

using Plots
using CSV
using DataFrames

gr()
Plots.GRBackend()

data = CSV.File("data/measures.csv") |> DataFrame

x = 1:2048
y = data[1, 2:end] # retrieve the spectrum of the first row

plot(x, y)
指令 data[1, 2:end]检索正确的值,但似乎我需要在将其传递给 plot 之前转换为不同的类型功能 ?
我收到以下错误:
ERROR: Cannot convert DataFrameRow{DataFrame, DataFrames.SubIndex{DataFrames.Index, UnitRange{Int64}, UnitRange{Int64}}} to series data for plotting
Stacktrace:
[1] error(s::String)
@ Base .\error.jl:33
[2] _prepare_series_data(x::DataFrameRow{DataFrame, DataFrames.SubIndex{DataFrames.Index, UnitRange{Int64}, UnitRange{Int64}}})
@ RecipesPipeline ~\.julia\packages\RecipesPipeline\CirY4\src\series.jl:8
[3] _series_data_vector(x::DataFrameRow{DataFrame, DataFrames.SubIndex{DataFrames.Index, UnitRange{Int64}, UnitRange{Int64}}}, plotattributes::Dict{Symbol, Any})
@ RecipesPipeline ~\.julia\packages\RecipesPipeline\CirY4\src\series.jl:27
[4] macro expansion
@ ~\.julia\packages\RecipesPipeline\CirY4\src\series.jl:144 [inlined]
[5] apply_recipe(plotattributes::AbstractDict{Symbol, Any}, #unused#::Type{RecipesPipeline.SliceIt}, x::Any, y::Any, z::Any)
@ RecipesPipeline ~\.julia\packages\RecipesBase\92zOw\src\RecipesBase.jl:282
[6] _process_userrecipes!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline ~\.julia\packages\RecipesPipeline\CirY4\src\user_recipe.jl:36
[7] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline ~\.julia\packages\RecipesPipeline\CirY4\src\RecipesPipeline.jl:70
[8] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
@ Plots ~\.julia\packages\Plots\SVksJ\src\plot.jl:172
[9] plot(::Any, ::Vararg{Any, N} where N; kw::Any)
@ Plots ~\.julia\packages\Plots\SVksJ\src\plot.jl:58
[10] plot(::Any, ::Any)
@ Plots ~\.julia\packages\Plots\SVksJ\src\plot.jl:52
[11] top-level scope
@ ~\path\to\my\script.jl:18
谢谢你的帮助!

最佳答案

我不确定你到底需要什么,但很可能你需要转换 DataFrameRowVector像这样:

plot(x, Vector(y))

关于dataframe - 在 Julia 中绘制 DataFrame 的子集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67121708/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com