小编Pav*_*dis的帖子

如何用ggplot指定不同的颜色

library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg))
p + geom_point(size=4)
Run Code Online (Sandbox Code Playgroud)

假设你有上述内容scatterplot.如何指定>= 25将绘制mpg 的点,red一个between 20 and 25 green0-20 blue

ggplot具体可以这样做吗?

r ggplot2

6
推荐指数
1
解决办法
1047
查看次数

熊猫数据帧到有序词典

有一个帖子,其中熊猫数据帧被转换为字典以供进一步处理.

执行此操作的代码是:

df = pd.read_excel(open('data/file.xlsx', 'rb'), sheetname="Sheet1")
dict = df.set_index('id').T.to_dict('dict')
Run Code Online (Sandbox Code Playgroud)

产生这样的东西: {column -> {index -> value}}

有没有一个快速的方法,而不是这个{column -> {index -> value}}得到这个:OrderedDict(column, value)作为一个返回值?

目前,我正在使用从pandas生成的字典,并将这些值逐个分配到有序字典中.这不是最佳方式,因为订单是乱码的

示例输入:这样的Excel文件:

Unique_id | column1 | column2 | column3 | column 4
1         | 3       | 4       | 43      | 90
2         | 54      | 6       | 43      | 54
Run Code Online (Sandbox Code Playgroud)

输出应该是一个有序的字典,如下所示:

{1:[3,4,43,90], 2:[54,6,43,54]}
Run Code Online (Sandbox Code Playgroud)

python dictionary pandas

5
推荐指数
1
解决办法
3300
查看次数

如何将枚举值传递给构造函数

protected enum Category { Action, Fiction, Drama, Romance, SciFi, Poems, Kids } 
Run Code Online (Sandbox Code Playgroud)

我创建了这个enum类型,现在我必须为我的类创建一个构造函数.

public Book(String title, int code, List<String> authors, String publisher, int year, Category categ){
        this.title = title;
        this.code = code;
        this.authors = authors;
        this.publisher = publisher;
        this.year = year;
        this.category = ....;
}
Run Code Online (Sandbox Code Playgroud)

我不明白我将如何向构造函数传递枚举类型的值.

有人可以帮忙吗?

我知道这是初学者的问题,但我似乎无法在任何地方找到答案.

java enums constructor

3
推荐指数
2
解决办法
1万
查看次数

在R中读取非常小的数字

所以我正在尝试为我的数据集生成一些图,但我遇到了某些值的某些问题.

有些值非常小:1.62132528761108e-1916准确度很小,当它在R上读取时,它变成了0.00000000000e+00

我正在阅读我的数据:

df <- read.table("path/to/file", header = T, sep = ' ', numerals = "no.loss")
Run Code Online (Sandbox Code Playgroud)

即使numerals标志设置为no.loss,数字也会变为0.

我怎样才能读出确切的数字?

r read.table

3
推荐指数
1
解决办法
337
查看次数

标签 统计

r ×2

constructor ×1

dictionary ×1

enums ×1

ggplot2 ×1

java ×1

pandas ×1

python ×1

read.table ×1