我不知道是否有导入CSV文件的内容为记录阵列直接的方式,很多的方式是R的read.table()
,read.delim()
和read.csv()
家庭的进口数据与R的数据帧?
或者是使用csv.reader()然后应用类似的东西的最佳方法numpy.core.records.fromrecords()
?
我在git中运行了一个全局配置命令,使用.gitignore_global文件排除某些文件:
git config --global core.excludesfile ~/.gitignore_global
Run Code Online (Sandbox Code Playgroud)
有没有办法撤消全局创建此设置?
我想设置dtype
多列的s pd.Dataframe
(我有一个文件,我必须手动解析到列表列表,因为该文件不适合pd.read_csv
)
import pandas as pd
print pd.DataFrame([['a','1'],['b','2']],
dtype={'x':'object','y':'int'},
columns=['x','y'])
Run Code Online (Sandbox Code Playgroud)
我明白了
ValueError: entry not a 2- or 3- tuple
Run Code Online (Sandbox Code Playgroud)
我可以设置它们的唯一方法是循环遍历每个列变量并重铸astype
.
dtypes = {'x':'object','y':'int'}
mydata = pd.DataFrame([['a','1'],['b','2']],
columns=['x','y'])
for c in mydata.columns:
mydata[c] = mydata[c].astype(dtypes[c])
print mydata['y'].dtype #=> int64
Run Code Online (Sandbox Code Playgroud)
有没有更好的办法?
散点图矩阵的示例
matplotlib.pyplot中有这样的功能吗?
在以下示例中,如何根据每个面板中的数据获取y轴限制?
mt <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) + geom_point()
Run Code Online (Sandbox Code Playgroud)
这些都不会这样做:
mt + facet_grid(. ~ cyl, scales="free")
mt + facet_grid(. ~ cyl, scales="free_y")
Run Code Online (Sandbox Code Playgroud) 在GNU emacs中,每当我点击Ctrl-x Ctrl-b查看所有缓冲区时,窗口将被拆分以显示缓冲区列表,或者如果我的窗口已经拆分为2(例如,我将在下部窗口中运行一个shell) ,缓冲区列表出现在另一个窗口中.
我想要的行为是缓冲区列表出现在我的活动窗口中,这样我就可以选择我想要的缓冲区并继续在同一个窗口中工作,而不必去Ctrl-x Ctrl-o另一个缓冲区,选择缓冲区(带enter)并编辑在另一个窗口缓冲...我用Google搜索但它似乎不是一个普遍的愿望?我想知道是否有人有elispy(或其他)解决方案?
在R中,有一个函数被调用abline
,其中可以根据截距(第一个参数)和斜率(第二个参数)的规范在图上绘制一条线.例如,
plot(1:10, 1:10)
abline(0, 1)
Run Code Online (Sandbox Code Playgroud)
截距为0且斜率为1的直线横跨整个绘图范围.Matplotlib中有这样的功能吗?
I am trying to 'destructure' a dictionary and associate values with variables names after its keys. Something like
params = {'a':1,'b':2}
a,b = params.values()
Run Code Online (Sandbox Code Playgroud)
But since dictionaries are not ordered, there is no guarantee that params.values()
will return values in the order of (a, b)
. Is there a nice way to do this?
到目前为止,我有以下代码:
colors = ('k','r','b')
ax = []
for i in range(3):
ax.append(plt.axes())
plt.plot(datamatrix[:,0],datamatrix[:,i],colors[i]+'o')
ax[i].set(autoscale_on=True)
Run Code Online (Sandbox Code Playgroud)
通过autoscale_on=True
每个轴的选项,我认为每个绘图应该有自己的y轴限制,但看起来它们都共享相同的值(即使它们共享不同的轴).如何将它们设置为缩放以显示每个的范围datamatrix[:,i]
(只是显式调用.set_ylim()
?)而且,如何为datamatrix[:,2]
上面可能需要的第三个变量()创建偏移y轴?谢谢大家.
我想知道是否有人通过emacs shell使用ssh.我可以连接远程计算机,但我无法使用'emacs filename'打开文件来查看/编辑emacs,因为'终端类型'哑"功能不足以运行emacs"(通常emacs会在控制台内打开)通过终端连接).
尝试以这种方式使用emacs是一个坏主意,还是可以通过一些修复来实现?非常感谢!
python ×6
matplotlib ×3
emacs ×2
dictionary ×1
elisp ×1
genfromtxt ×1
ggplot2 ×1
git ×1
numpy ×1
pandas ×1
r ×1
scatter-plot ×1
scipy ×1
sorting ×1
ssh ×1