我正在创建一个 conda 环境:
conda env export --name root > myEnv.yml
Run Code Online (Sandbox Code Playgroud)
我在文件中手动将“root”替换为“myEnv”。这是在共享机器上完成的。然后我移动到另一个系统,我这样做:
conda env create -f myEnv.yml
name: my_env
channels:
file://somewhere//
otherpublicrepos
Run Code Online (Sandbox Code Playgroud)
不幸的是,在文件中有一个私人频道,我不得不将其删除
现在我(一个接一个)从 file:// 中的那些丢失的包错误中得到了很多,我必须手动从文件中删除它们。
如何仅安装公共存储库中可用的内容但最终创建环境?
-q 选项没有帮助,conda create输出
ResolvePackageNotFound: - ALIB 3.2.1 1
Run Code Online (Sandbox Code Playgroud)
并在不创造环境的情况下默默返回
我想使用scipy.stats.probplot对进行一些高斯测试mydata。
from scipy import stats
_,fit=stats.probplot(mydata, dist=stats.norm,plot=ax)
goodness_fit="%.2f" %fit[2]
Run Code Online (Sandbox Code Playgroud)
该文件说:
生成样本数据相对于指定理论分布(默认为正态分布)的分位数的概率图。probplot可以选择计算数据的最佳拟合线,并使用Matplotlib或给定的绘图函数对结果进行绘图。probplot生成概率图,请勿将其与QQ或PP图混淆。Statsmodels具有此类更广泛的功能,请参阅statsmodels.api.ProbPlot。
但是如果用谷歌搜索概率图,它是PP图的通用名称,而文档则说不要混淆这两件事。
现在我很困惑,这个函数在做什么?
我有一个混合的pd.DataFrame:
import pandas as pd
import numpy as np
df = pd.DataFrame({ 'A' : 1.,
'B' : pd.Timestamp('20130102'),
'C' : pd.Timestamp('20180101'),
'D' : np.random.rand(10),
'F' : 'foo' })
df
Out[12]:
A B C D F
0 1.0 2013-01-02 2018-01-01 0.592533 foo
1 1.0 2013-01-02 2018-01-01 0.819248 foo
2 1.0 2013-01-02 2018-01-01 0.298035 foo
3 1.0 2013-01-02 2018-01-01 0.330128 foo
4 1.0 2013-01-02 2018-01-01 0.371705 foo
5 1.0 2013-01-02 2018-01-01 0.541246 foo
6 1.0 2013-01-02 2018-01-01 0.976108 foo
7 …Run Code Online (Sandbox Code Playgroud) 我必须检查是否foo是 的属性myclass。
现在我做
def myclass():
try:
self.foo
except AttributeError:
self.foo = 'default'
Run Code Online (Sandbox Code Playgroud)
虽然我认为我应该做
if not hasattr(self,'foo'):
self.foo = 'default'
Run Code Online (Sandbox Code Playgroud)
这两种方法之间有什么区别吗?应该首选哪一种?
我正在寻找以下标准:
我有一个数据框和一个列表
df = pd.DataFrame({'A':[1,2,3], 'B':[4,5,6]})
mylist= [10,20,30,40,50]
Run Code Online (Sandbox Code Playgroud)
我希望在数据帧的每一行中都有一个列表作为元素.如果我喜欢这里,
df['C'] = mylist
Run Code Online (Sandbox Code Playgroud)
Pandas试图每行播放一个值,所以我得到一个错误Length of values does not match length of index.
A B C
0 1 4 [10,20,40,50]
1 2 5 [10,20,40,50]
2 3 6 [10,20,40,50]
Run Code Online (Sandbox Code Playgroud) 我有一个像
v = np.array([1.0,1.0,2.0,2.0,2.0,2.0,...])
Run Code Online (Sandbox Code Playgroud)
我需要识别数组中的所有常量段,如
[{value:1.0,location:0,duration:2},..]
Run Code Online (Sandbox Code Playgroud)
效率是主要指标
如何检查myname
google脚本中是否存在工作表,以避免insertSheet在现有名称上使用错误?
以下不起作用
var ss = SpreadsheetApp.getActiveSpreadsheet();
var itt = ss.getSheetByName('_EmailList');
if (! (itt.hasNext())){
ss.insertSheet('_EmailList');}
Run Code Online (Sandbox Code Playgroud) 我正在尝试将大型数据集提供给keras模型。数据集不适合内存。当前存储为一系列hd5f文件
我想使用训练我的模型
model.fit_generator(my_gen, steps_per_epoch=30, epochs=10, verbose=1)
Run Code Online (Sandbox Code Playgroud)
但是,在我可以在线找到的所有示例中,这些示例my_gen仅用于对已加载的数据集执行数据扩充。例如
def generator(features, labels, batch_size):
# Create empty arrays to contain batch of features and labels#
batch_features = np.zeros((batch_size, 64, 64, 3))
batch_labels = np.zeros((batch_size,1))
while True:
for i in range(batch_size):
# choose random index in features
index= random.choice(len(features),1)
batch_features[i] = some_processing(features[index])
batch_labels[i] = labels[index]
yield batch_features, batch_labels
Run Code Online (Sandbox Code Playgroud)
就我而言,它必须像
def generator(features, labels, batch_size):
while True:
for i in range(batch_size):
# choose random index in features
index= # SELECT THE NEXT FILE
batch_features[i] …Run Code Online (Sandbox Code Playgroud) 我有一份詹金斯的工作。这非常简单:从 git 中拉取,然后运行构建。
构建只是一步:
执行窗口命令批处理
在我的用例中,我需要运行一些 python 脚本。有些会失败,有些则不会。
python a.py
python b.py
Run Code Online (Sandbox Code Playgroud)
什么决定了构建的最终状态?看来我可以通过以下方式编辑:
echo @STABLE > build.proprieties
Run Code Online (Sandbox Code Playgroud)
但如果用户没有指定,STABLE/UNSTABLE 状态是如何分配的呢?如果 b.py 引发错误并失败会发生什么?
我正在用python编写一个类。
class my_class(object):
def __init__(self):
# build my objects
def foo(self,*args,**kwargs):
# do something with them
Run Code Online (Sandbox Code Playgroud)
然后我想扩展这个类:
class my_extended_class(my_class):
Run Code Online (Sandbox Code Playgroud)
但我无法弄清楚访问父方法的正确方法是什么。
我可以吗:
1)创建一个父对象的实例?在构造函数时
def __init__(self):
self.my_father=my_class()
# other child-specific statements
return self
def foo(self,*args,**kwargs):
self.my_father.foo(*args,**kwargs)
# other child-specific statements
return self
Run Code Online (Sandbox Code Playgroud)
2)“直接”调用父方法?
def foo(self,*args,**kwargs):
my_class.foo(*args,**kwargs)
# other child-specific statements
return self
Run Code Online (Sandbox Code Playgroud)
3)其他可能的方式?
python ×8
class ×2
numpy ×2
oop ×2
pandas ×2
aggregate ×1
algorithm ×1
anaconda ×1
attributes ×1
build ×1
conda ×1
dataframe ×1
devops ×1
generator ×1
inheritance ×1
jenkins ×1
keras ×1
list ×1
matplotlib ×1
persistence ×1
plot ×1
reflection ×1
statistics ×1
virtualenv ×1