假设我有两个数组,如下所示:
如何找到满足以下两个条件的索引?
因此,对于我的示例,我预计返回值为索引 5。我想格式将如下所示:
findfirst(x -> x > 80 \union y -> y> 30, x,y)
但这不起作用..
另外,在我的例子中,x 和 y 是数据框中的列,但进行索引搜索也不起作用。
假设我有一个日期时间,我想向该日期时间添加任意时间段并获取新的日期时间。例如,我想查找除夕后 333 小时后的日期和时间。
出现两个问题:
我的问题基本上是如何将时间加在一起?
代码
julia> dt = DateTime(2021,1)
2021-01-01T00:00:00
julia> t = Time(333)
ERROR: ArgumentError: Hour: 333 out of range (0:23)
julia> t = Time(1)
01:00:00
julia> dt + t
ERROR: MethodError: no method matching +(::DateTime, ::Time)
Closest candidates are:
+(::Any, ::Any, ::Any, ::Any...) at operators.jl:560
Run Code Online (Sandbox Code Playgroud) 假设我有以下示例代码
using PlotlyJS
using CSV, DataFrames
df = dataset(DataFrame, "iris")
plot(
df, x=:sepal_width, y=:sepal_length, color=:species,
mode="markers"
)
Run Code Online (Sandbox Code Playgroud)
我该如何指定每个组的颜色,例如,如果我希望 setosa 为黄色?
这正是Plotly-Express: How to fix the color mapping when set color by column name ,但我在 julia 中需要它。我无法让 color_discrete_map 工作...