我想从 github 安装以下包。我尝试在我的环境中使用以下命令来安装
(nlpEnvJl) pkg> add "https://github.com/yeesian/LeafletJS.jl/tree/master/src"
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误,
错误:在包中找不到项目文件,https://github.com/yeesian/LeafletJS.jl
可能subdir
需要指定
关于如何安装有什么想法吗?我必须先将其克隆到本地存储库吗?如果是这样我如何从本地路径安装?
干杯 提前致谢
您好,我收到以下警告(导入下方的波浪线)import "numpy" could not be resolved Pylance(reportMissingModuleSource)
,。执行代码没有任何问题 - 工作正常,只是警告(波浪线)。
在下面的 github 页面中,它声明使用以下行更改 Settings.JSON "python.analysis.extraPaths": ["./sources"]
。
然而这没有用。我还尝试添加当前目录的路径,后跟“源”,如图所示。但它也不起作用。
我/home/imantha/workspace/python
使用bash
withcode .
命令从这个入口点打开 vs code。
谁能知道我如何添加正确的路径。
由于我的 Mac 带有 M1 芯片,因此无法使用常规版本的 anaconda 安装 Tensorflow,因此我使用 conda 安装miniforge3-MacOSX-arm64.sh
。但是现在我无法使用 python 2.7 创建环境。
conda create --name osmEnv python=2.7
Run Code Online (Sandbox Code Playgroud)
我最终出现以下错误,
PackagesNotFoundError: The following packages are not available from current channels:
- python=2.7
Current channels:
- https://conda.anaconda.org/conda-forge/osx-arm64
- https://conda.anaconda.org/conda-forge/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Run Code Online (Sandbox Code Playgroud)
正如添加新通道(原始问题)的评论中所建议的,我也尝试使用 anaconda 通道,
conda create --name osmEnv -c anaconda python=2.7
Run Code Online (Sandbox Code Playgroud)
这导致了同样的错误。关于如何安装 python 2.7 …
我想从.osm.pbf
文件中提取一些信息。我查看了OpenStreetMapX.jl
包但没有找到读取此数据的函数。我想知道是否有人知道读取这些数据的方法。或者有没有一种方法可以转换.osm.pbf
为.osm
文件,以便我发现只需使用包get_map_data()
提供的方法OpenStreetMapX
我已经使用 miniforge 安装了 conda。由于我的 mac 有 m1 芯片,我必须使用安装 condaMiniforge3-MacOSX-arm64.sh
才能使 tensorflow 工作。不幸的是这个版本(minforge/minconda arm64)由于某种原因没有python2。由于我的另一个项目需要 python2(不需要tensorflow),所以我决定安装 anaconda3。
但现在我不知道如何在两个 conda 版本(anaconda3 和 miniconda/miniforge3)之间切换。
例如,当我进入activate conda
终端时,它会激活base
miniforge版本的环境。如何激活base
anaconda版本的环境。这样我就可以在那里创建 python2 环境(anaconda3)。
我想知道为什么 not 运算符不使用数组广播/元素操作。例如,如果我输入
x = Array{Any}([1,2,3,4,missing,6])
!ismissing.(x)
Run Code Online (Sandbox Code Playgroud)
我收到一个错误 ERROR: MethodError: no method matching !(::BitArray{1})
但如果我尝试 ismissing.(x) 它工作正常,
ismissing.(x)
#out > 6-element BitArray{1}: 0 0 0 0 1 0
Run Code Online (Sandbox Code Playgroud)
并且在没有广播的情况下打字也可以作为一个整体(整个数组的一个输出)
!ismissing(x)
#out > True
Run Code Online (Sandbox Code Playgroud)
所以我想知道是否有可能获得与使用“!”类似的结果。操作员。
我想使用函数过滤字典filter()
,但我遇到了麻烦。我希望完成的是,返回值的某些条件的密钥。但是我遇到了方法错误
using Agents: AbstractAgent
# Define types
mutable struct Casualty <: AbstractAgent
id::Int
ts::Int
rescued::Bool
function Casualty(id,ts; rescued = false)
new(id,ts,rescued)
end
end
mutable struct Rescuer <: AbstractAgent
id::Int
actions::Int
dist::Float64
function Rescuer(id; action = rand(1:3) , dist = rand(1)[1])
new(id,action,dist)
end
end
cas1 = Casualty(1,2)
cas2 = Casualty(2,3)
resc1 = Rescuer(3)
agents = Dict(1=> cas1, 2 => cas2, 3 => resc1)
Run Code Online (Sandbox Code Playgroud)
现在要过滤
filter((k,v) -> v isa Casualty, agents)
# ERROR: MethodError: no method matching (::var"#22#23")(::Pair{Int64, AbstractAgent})
# …
Run Code Online (Sandbox Code Playgroud) 我想将数据框中的某些列转换为 timedelta 值。在此示例中,列“第 1 天”、“第 2 天”、“第 3 天”需要从浮点值转换为时间增量值(以天为单位)。
#trail dataframe
newdf = pd.DataFrame({'days 1' : [14.3], 'val 1' : [147], 'days 2' : [16.7],'val 2' : [148], 'days 3' : [17.7],'val 3' : [149]})
Run Code Online (Sandbox Code Playgroud)
我尝试使用该pd.to_timedelta()
函数进行转换,但出现错误arg must be a string, timedelta, list, tuple, 1-d array, or Series
newdf[['days 1','days 2', 'days 3']] = pd.to_timedelta(newdf[['days 1','days 2','days 3']],unit = 'D')
Run Code Online (Sandbox Code Playgroud)
然而,当我这样分隔每一列时,代码运行良好。
newdf['days 1'] = pd.to_timedelta(newdf['days 1'],unit = 'D')
newdf['days 2'] = pd.to_timedelta(newdf['days 2'],unit = 'D')
newdf['days 3'] = …
Run Code Online (Sandbox Code Playgroud) 我想过滤数据帧并将值附加到数据帧中的新/现有列。例如,在下面的数据框中,我想将 0.7 的值附加到列 pre-mean 中,其中月份值等于 11。所以换句话说,pre_mean 列的第 2 到 5 行应该包含 0.7 的值,而所有其他列都应该有一个 NaN 值。
我试过这样的事情,但当然这是不正确的。
df[:pre_mean] = ifelse.(df[:month] .== 11, 0.7, df)
Run Code Online (Sandbox Code Playgroud)
在 python 中,你可以使用 pd.apply 或 np.where 函数来做到这一点,
#How to do in python
df["pre_mean"] = np.where(df["month"] == 11, 0.7, None)
Run Code Online (Sandbox Code Playgroud)
但我不知道如何在 Julia 中实现这一目标?有任何想法吗?
我想知道是否存在使用不操作的somesort与功能这样的方式ismissing()
或isempty()
例如,如果我想要做这样的事情,我怎么会去了解它。
x = Array[]
y = missing
if x not isempty(x)
# do something
elif not ismissing(y)
# do something
end
Run Code Online (Sandbox Code Playgroud)
这当然是不正确的,空数组可以用if length(x) >0
. 但我想知道是否有一种方法可以像在 python 中那样使用非运算符。例如,在 python numpy 库中,我可以做这样的事情来实现这一点,
y = np.nan
if y is not np.nan:
#do something
Run Code Online (Sandbox Code Playgroud)