有谁知道如何在Mac上安装gitk?
从他们的官方网站来看,似乎gitk带有git,但我的git(git version 1.7.12.4 (Apple Git-37))的版本没有附带gitk.
brew install gitk 不适用于gitk.
版本信息(从评论中复制):
如何将给定数据帧的第一行和最后一行作为pandas中的新数据帧提取?
我试图用来iloc选择所需的行,然后concat如下所示:
df=pd.DataFrame({'a':range(1,5), 'b':['a','b','c','d']})
pd.concat([df.iloc[0,:], df.iloc[-1,:]])
Run Code Online (Sandbox Code Playgroud)
但是这不会产生一个熊猫数据帧:
a 1
b a
a 4
b d
dtype: object
Run Code Online (Sandbox Code Playgroud) 我正在使用Python的(2.7)argparse工具,并希望按选项自动按字母顺序排序.
默认情况下,帮助条目按照添加顺序进行排序*,如下所示:
p = argparse.ArgumentParser(description='Load duration curves and other plots')
p.add_argument('--first', '-f', type=int, default=1, help='First Hour')
p.add_argument('--dur', '-d', type=int, default=-1, help='Duration in Hours. Use -1 for all')
p.add_argument('--title', '-t', help='Plot Title (for all plots), default=file name')
p.add_argument('--interp', '-i', action="store_true", default=True,
help='Use linear interpolation for smoother curves')
...
args = p.parse_args()
Run Code Online (Sandbox Code Playgroud)
当被称为python script -h产生时:
usage: script.py [-h] [--first FIRST] [--dur DUR] [--title TITLE] [--interp]
Load duration curves and other plots
optional arguments:
-h, --help show this help message and …Run Code Online (Sandbox Code Playgroud) 是否可以删除或禁用argparse中的参数,以便它不会显示在帮助中?怎么样?
添加新参数很容易:
parser = argparse.ArgumentParser()
parser.add_argument('--arg1', help='Argument 1')
parser.add_argument('--arg2', help='A second one')
Run Code Online (Sandbox Code Playgroud)
我知道你可以通过指定"resolve"冲突处理程序来覆盖带有新定义的参数:
#In one script that should stand-alone and include arg1:
parser = argparse.ArgumentParser(conflict_handler='resolve')
parser.add_argument('--arg1', help='Argument 1')
parser.add_argument('--arg2', help='A second one')
#In another script with similar options
parser.add_argument('--arg1', help='New number 1')
Run Code Online (Sandbox Code Playgroud)
但这仍然包括帮助消息中的arg1和结果parse_args是否有类似的东西
#Wishful thinking
#In another script with similar options, that shouldn't include arg1
parser.remove_argument('--arg1')
Run Code Online (Sandbox Code Playgroud)
或者另一种合理简单的方法来实现这一目标?
另外:如果论证是位置论证,那么方法会不同吗?
注:排除故障arg1解析的建议后,这里是参数仍显示在帮助
我想在基于SciPy的模拟中使用准随机序列,特别是Sobol.关于现有高效套餐的任何建议?
我开始在我的Mac上运行从C代码(使用XCode 4.3)编译的MATLAB(R2012a)的MEX文件(运行OSX 10.7.3,Lion).我已经安装了MATLAB提供的XCode补丁,该补丁配置MATLAB以在XCode 4.2+下使用新的llvm-gcc编译器,但是我仍然在尝试使用以下命令编译示例文件时出现以下错误mex timestwo.c:
/Applications/MATLAB_R2012a.app/extern/include/matrix.h:852:20: error: stdlib.h: No such file or directory
In file included from timestwo.c:1:
/Applications/MATLAB_R2012a.app/extern/include/mex.h:161:19: error: stdio.h: No such file or directory
Run Code Online (Sandbox Code Playgroud)
编译然后打破
mex: compile of ' "timestwo.c"' failed.
Error using mex (line 206)
Unable to complete successfully.
Run Code Online (Sandbox Code Playgroud)
显然,编译器找不到标准库头文件目录,但是需要更改才能成功编译?
我在笔记本电脑(OSX)上有一个裸露的本地git存储库,可以将它当作位于远程桌面(RDP)上的远程(Window 7)虚拟机上的克隆的来源。
首先,我在RDP配置中重定向了笔记本电脑存储库文件夹,因此它看起来像是虚拟机的文件夹。有了这个,我可以从笔记本电脑存储库中克隆和提取文件了。但是当我尝试推送时,出现以下错误:
C:\Proj\repo>git push origin
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (9/9), done.
remote: error: insufficient permission for adding an object to repository database ./objects
remote: fatal: failed to write object
fatal: sha1 file '<stdout>' write error: Broken pipe
error: failed to push some refs to '//tsclient/bare_for_rdp'
Run Code Online (Sandbox Code Playgroud)
尽管有错误,但我认为这不是笔记本电脑上的权限问题,因为我使整个目录世界都可写。(chmod -R a+w *)。看到这个帖子
另外,由于没有特别大的文件,因此我认为断开的管道与缓冲区大小问题无关。
关于如何使它起作用的任何想法?
我正在尝试在 Python (2.7) 下使用 subprocess32.Popen() 打开多个子进程——每个子进程都运行相同的预编译二进制文件,但对唯一目录中的文件进行操作。大多数情况下一切正常,但我经常收到 OSError [Errno 14] 错误地址。这是代码:
self.gld_stdout_file = open('stdout', 'w+')
self.gld_stderr_file = open('stderr', 'w+')
...
subprocess.Popen(string.join(gld_open_str, " "), shell=True, stderr=self.gld_stderr_file,
stdout=self.gld_stdout_file, bufsize=-1, close_fds=ON_POSIX,
env={'TEMP':temp_path})
Run Code Online (Sandbox Code Playgroud)
大约 5-10% 的尝试使用 Popen() 时会发生此错误,而同一循环中的其他 Popen() 调用工作正常。环顾四周,似乎这可能来自较低级别的套接字调用中的错误,我没有直接连接。(例如这里或这里)
关于我为什么会收到此错误的任何想法?
更重要的是:
我该如何解决?
作为参考,我们正在使用 subprocess32,据说它可以通过多个子流程调用提高稳定性。此外,如果相关,整个方案被包装成一个更大的基于 MPI 的 HPC 并行调用,以便多个计算节点同时尝试做同样的事情。由于担心多次尝试执行同一个文件可能会出现冲突或文件系统挑战,我们已经在执行之前将二进制文件复制到这些节点中的每一个。
另外,我看到了与以下相同的问题shell=False:
subprocess.Popen(gld_open_list, shell=False, stderr=self.gld_stderr_file,
stdout=self.gld_stdout_file, bufsize=-1, close_fds=ON_POSIX,
env={'TEMP':temp_path})
Run Code Online (Sandbox Code Playgroud) 是否有一种干净/自动的方式来转换%在R 中用百分比(带尾随符号)格式化的CSV值?
以下是一些示例数据:
actual,simulated,percent error
2.1496,8.6066,-300%
0.9170,8.0266,-775%
7.9406,0.2152,97%
4.9637,3.5237,29%
Run Code Online (Sandbox Code Playgroud)
哪个可以使用:
junk = read.csv("Example.csv")
Run Code Online (Sandbox Code Playgroud)
但是所有%列都被读取为字符串并转换为因子:
> str(junk)
'data.frame': 4 obs. of 3 variables:
$ actual : num 2.15 0.917 7.941 4.964
$ simulated : num 8.607 8.027 0.215 3.524
$ percent.error: Factor w/ 4 levels "-300%","-775%",..: 1 2 4 3
Run Code Online (Sandbox Code Playgroud)
但我希望它们是数值.
read.csv还有一个附加参数吗?有没有办法轻松过帐所需的列以转换为数值?其他方案?
注意:当然在这个例子中我可以简单地重新计算值,但是在我的实际应用程序中使用更大的数据文件这是不实际的.