我在Ubuntu 10.04上使用emacs 23.1.1.我希望使用2空格缩进在Python中编程.emacs看起来有python的默认模式(python.el?).
我把以下内容放在我的.emacs中:
;; Only spaces, no tabs
(setq indent-tabs-mode nil)
;; Always end a file with a newline
(setq require-final-newline nil)
;; Don't know which of these might work
(setq-default tab-width 2)
(setq-default python-indent 2)
(setq-default py-indent-offset 2)
Run Code Online (Sandbox Code Playgroud)
当我编辑Python文件时,它使用4空格缩进.当我尝试Ch v python-indent时,它说:
python-indent's value is 4
Local in buffer webpage_cache.py; global value is 2
This variable is safe as a file local variable if its value
satisfies the predicate `integerp'.
Documentation:
Number of columns for a unit of indentation …Run Code Online (Sandbox Code Playgroud) 假设我使用Google的Gson库将JSON解析为Java数据结构.
如果存在没有相应JSON的Java字段,是否有一种简单的方法可以抛出异常?也就是说,我希望JSON拥有Java结构中的所有字段.
有几个地方说Hadoop作业中默认的减少器数是1.您可以使用mapred.reduce.tasks符号手动设置减速器的数量.
当我运行Hive作业时(在Amazon EMR,AMI 2.3.3上),它有一些大于1的减速器.看看工作设置,有些东西已经设置了mapred.reduce.tasks,我认为是Hive.它如何选择这个数字?
注意:这是运行Hive作业时的一些消息,应该是一个线索:
...
Number of reduce tasks not specified. Estimated from input data size: 500
In order to change the average load for a reducer (in bytes):
set hive.exec.reducers.bytes.per.reducer=<number>
In order to limit the maximum number of reducers:
set hive.exec.reducers.max=<number>
In order to set a constant number of reducers:
set mapred.reduce.tasks=<number>
...
Run Code Online (Sandbox Code Playgroud) 在Hive上,我相信count(不同)将比group-by更可能导致减速器的工作量不平衡,并最终导致一个悲伤的减速器磨损.下面的示例查询.
为什么?
示例查询:
select count(distinct user)
from some_table
Run Code Online (Sandbox Code Playgroud)
分组版本(建议更快):
select count(*) from
(select user
from some_table
group by user) q
Run Code Online (Sandbox Code Playgroud)
注意:本演示文稿的幻灯片26 描述了该问题.
我正在尝试在基于debian(jessie)和Anaconda的docker容器中安装rJava.
作为根,我做到了
$ apt-get update && apt-get install -y --no-install-recommends \
default-jdk default-jre libicu-dev
Run Code Online (Sandbox Code Playgroud)
然后
$ R CMD javareconf
Java interpreter : /usr/lib/jvm/jdk1.8.0_121/jre/bin/java
Java version : 1.8.0_121
Java home path : /usr/lib/jvm/jdk1.8.0_121
Java compiler : /usr/lib/jvm/jdk1.8.0_121/bin/javac
Java headers gen.: /usr/lib/jvm/jdk1.8.0_121/bin/javah
Java archive tool: /usr/lib/jvm/jdk1.8.0_121/bin/jar
trying to compile and link a JNI program
detected JNI cpp flags : -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux
detected JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
gcc -std=gnu99 -I/opt/conda/lib/R/include -DNDEBUG -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux -I/opt/conda/include -fpic -I/opt/conda/include -c conftest.c -o conftest.o
conftest.c:1:17: …Run Code Online (Sandbox Code Playgroud) 下面是代码和图表。
该图具有三个方面。the_plot我在哪里可以找到它具有三个方面?是的,我可以从mtcars数据框中得到它,或者the_plot$data,但我不想重新创建数据分析。相反,我想检查 的图形元素the_plot,因此我不必在多个地方复制应用程序逻辑。 the_plot$facet没有显示任何我认识的东西,其他绘图变量也没有显示。
我正在使用 tidyverse 1.3.0。
library(tidyverse)
data(mtcars)
the_plot<-ggplot(mtcars, aes(mpg, disp, group=cyl)) + facet_wrap(~cyl) + geom_point()
the_plot
Run Code Online (Sandbox Code Playgroud)
假设您有以下文件:
textfield,datetimefield,numfield
foo,2008-07-01 17:50:55.004688,1
bar,2008-07-02 17:50:55.004688,2
Run Code Online (Sandbox Code Playgroud)
读取.csv的Ruby代码如下:
#!/usr/bin/env ruby
require 'csv'
csv = CSV($stdin, :headers => true, :converters => :all)
csv.each do |row|
print "#{row}"
the_date = row['datetimefield'].to_date
end
Run Code Online (Sandbox Code Playgroud)
该代码提供此错误消息:
./foo2.rb:8:in `block in <main>': undefined method `to_date' for "2008-07-01 17:50:55.004688":String (NoMethodError)
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?
我已经阅读了文档,但我没理解.
编辑:是的,我可以单独解析字段.这个问题的关键是我想学习如何使用记录的转换器功能.
假设我有一个带有长行的定界文档的文件:
some_string = '''
very long lines here, 20 lines each of length 500
'''
Run Code Online (Sandbox Code Playgroud)
如何忽略该定界文档中的所有 flake8“行太长”错误,而不排除整个文件的检查?