如果这个问题太宽泛,我会提前道歉.我来自MATLAB世界,对Python的经验相对较少.
在花了一些时间阅读几个基于Python的环境和科学计算的发行版后,我觉得我仍然不完全理解解决方案的前景或一些值得注意的包之间的确切关系,包括:
进一步来说:
不太重要的是,是否有其他类似于上述类似功能的软件包?
提前致谢
几周前我在GitHub上安装了scikit-learn:
pip install git+git://github.com/scikit-learn/scikit-learn@master
Run Code Online (Sandbox Code Playgroud)
我去了GitHub,从那以后主分支发生了一些变化.
如何更新我的本地安装scikit-learn?
我试过pip install scikit-learn --upgrade但是我得到了:
Requirement already up-to-date
Cleaning up ...
Run Code Online (Sandbox Code Playgroud) 在IPython中是否有命令清除屏幕?
编辑:作为@Saher以下提到,我可以清洁屏幕使用import os; os.system('CLS'),但有没有办法做到这一点,而无需导入所有的os?
我有
cmd = subprocess.Popen('dir',shell=True,stdout=subprocess.PIPE)
for line in cmd.stdout:
columns = line.split(' ')
print (columns[3])
Run Code Online (Sandbox Code Playgroud)
在第3行中有错误类型Str不支持缓冲区API.
我在使用Python 3.3时做错了什么
lexsort_depth多索引数据帧究竟是什么?为什么必须对索引进行排序?
例如,我注意到,在手动构建包含df三个级别的列的多索引数据框之后,如果我尝试执行此操作:
idx = pd.IndexSlice
df[idx['foo', 'bar']]
Run Code Online (Sandbox Code Playgroud)
我明白了:
KeyError: 'Key length (2) was greater than MultiIndex lexsort depth (0)'
Run Code Online (Sandbox Code Playgroud)
而在这一点上,df.columns.lexsort_depth是0
df = df.sortlevel(0,axis=1)
Run Code Online (Sandbox Code Playgroud)
然后横截面索引工作.为什么?究竟是什么lexsort_depth,为什么排序sortlevel修复这种类型的索引?
我的代码片段的字体大小相对于Wiki的默认字体大小而言太小,这使得它们难以阅读(参见下面的示例).我有什么办法可以改变它吗?
例:

生成上述代码的代码是:
==== Histograms ====
This is the code to compute the histogram:
<source lang="matlab">
nEls = numel(unique_vals);
edges = zeros(nEls+2,1);
</source>
Run Code Online (Sandbox Code Playgroud) 在最近的MATLAB版本中,可以在%%使用之前从两行之间执行代码区域Ctrl-Enter.这样的区域称为代码单元,它允许快速的代码测试和调试.
例如
%% This is the beginning of the 1st cell
a = 5;
%% This is the end of the 1st cell and beginning of the 2nd cell
% This is just a comment
b = 6;
%% This is the end of the 2nd cell
Run Code Online (Sandbox Code Playgroud)
有没有支持类似功能的python编辑器?
编辑:我刚刚发现Spyderlib支持用F9支持"阻塞"执行(用空行分隔的代码区域),但是正如这个帖子所提到的,这个特性仍然不是很强大(特别是与循环结合).
我有一个DataFrame"df"与(时间,股票代码)Multiindex和bid/ask/etc数据列:
tod last bid ask volume
time ticker
2013-02-01 SPY 1600 149.70 150.14 150.17 1300
SLV 1600 30.44 30.38 30.43 3892
GLD 1600 161.20 161.19 161.21 3860
我想使用多个键选择二级(level = 1)横截面.现在,我可以用一把钥匙来做,即
df.xs('SPY', level=1)
这给了我SPY的时间序列.选择多键横截面的最佳方法是什么,即SPY和GLD的组合横截面,如:
df.xs(['SPY', 'GLD'], level=1)
?
在Python中工作(例如运行脚本)时,如何找到脚本所在的git存储库根目录的路径?
到目前为止,我知道我可以获得当前路径:
path_to_containing_folder = os.path.dirname(os.path.realpath(__file__))
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能找到git存储库所在的位置?
python ×8
pandas ×3
git ×2
geshi ×1
github ×1
ide ×1
ipython ×1
matlab ×1
matplotlib ×1
mediawiki ×1
numpy ×1
pip ×1
python-3.3 ×1
scikit-learn ×1
subprocess ×1
windows ×1