更新:Brandon Bertelsen的回答:
布兰登的答案产生以下输出.它不会像Rstudio那样产生漂亮的表格或突出显示代码,并且它会在一些带有unicode的html文件上崩溃,因此我不会使用它来自动化我的电子邮件报告.
我目前的方法是使用Rstudio编译为html,在chrome中打开html文档,然后将html文档复制并粘贴到gmail中.这很好用,请看这个要点:https://gist.github.com/nelsonauner/a68b5a808c232ce7817e
是否有一种简单的方法可以将R降价文档作为电子邮件正文发送,以便电子邮件的正文与使用Rstudio的"编织HTML"的结果类似?
这里有一个基本的可重复使用例子knitr
,rmarkdown
和mailR
---
title: "Report for email"
output:
html_document:
self_contained: no
---
```{r}
summary(cars)
```
You can also embed plots, for example:
```{r, echo=FALSE}
plot(cars)
```
Run Code Online (Sandbox Code Playgroud)
我正在使用,self_contained: no
因为默认的base64编码不起作用mailR
(Yihui在此SO帖子中推荐)
# compile using rmarkdown
library(rmarkdown)
rmarkdown::render("example.Rmd")
library(mailR)
send.mail(from = "me@gmail.com",
to = "me@gmail.com",
subject = "R Markdown Report - rmarkdown",
html = T,
inline = T,
body = "example.html",
smtp …
Run Code Online (Sandbox Code Playgroud) 可以通过获取可能成员的列表来创建枚举,我这样做是这样的:
# example_issue.py
import enum
yummy_foods = ["ham", "cheese"]
foods = enum.Enum("Foods", yummy_foods)
cheese = foods.cheese
Run Code Online (Sandbox Code Playgroud)
这看起来不错,运行良好,但 mypy 返回
example_issue.py:4: error: Enum() expects a string, tuple, list or dict literal as the second argument
example_issue.py:5: error: "Type[foods]" has no attribute "cheese"
Found 2 errors in 1 file (checked 1 source file)
Run Code Online (Sandbox Code Playgroud)
mypy 在这里做什么,为什么它不能遵循 that foods
can take any value in yummy_foods
?
Scikitlearn的PolynomialFeatures有助于生成多项式特征.
这是一个简单的例子:
import numpy as np
import pandas as pd
from sklearn.preprocessing import PolynomialFeatures
# Example data:
X = np.arange(6).reshape(3, 2)
# Works fine
poly = PolynomialFeatures(2)
pd.DataFrame(poly.fit_transform(X))
0 1 2 3 4 5
0 1 0 1 0 0 1
1 1 2 3 4 6 9
2 1 4 5 16 20 25
Run Code Online (Sandbox Code Playgroud)
问题:是否有能力仅将多项式变换应用于指定的要素列表?
例如
# Use previous dataframe
X2 = X.copy()
# Categorical feature will be handled
# by a one hot encoder in another …
Run Code Online (Sandbox Code Playgroud) 我每天都会观察到以下时间序列数据:
series <- c(10, 25, 8, 27, 18, 21, 12, 9, 31, 18, 8, 30, 14, 13, 10, 14,
14, 14, 6, 9, 22, 21, 22, 8, 7, 6, 22, 21, 36, 16, 2, 13, 23,
40, 12, 27, 18, 10, 11, 37, 44, 30, 40, 25, 13, 11, 58, 56, 46,
39, 28, 27, 19, 20, 97, 90, 70, 73, 30, 22, 97, 34)
Run Code Online (Sandbox Code Playgroud)
并希望tbats
从R forecasts
包中使用它.我还想用每周相关性对它进行建模:
library(forecast)
x.msts = msts(series,seasonal.periods = 7)
model <- tbats(x.msts) …
Run Code Online (Sandbox Code Playgroud) 表结构是
+------------+---------+
| Animals | Herbs |
+------------+---------+
| [Cat, Dog] | [Basil] |
| [Dog, Lion]| [] |
+------------+---------+
Run Code Online (Sandbox Code Playgroud)
所需的输出(不关心此列表的排序):
unique_things
+------------+
[Cat, Dog, Lion, Basil]
Run Code Online (Sandbox Code Playgroud)
第一次尝试是这样的
SELECT ARRAY_CAT(ARRAY_AGG(DISTINCT(animals)), ARRAY_AGG(herbs))
Run Code Online (Sandbox Code Playgroud)
但这会产生
[[Cat, Dog], [Dog, Lion], [Basil], []]
Run Code Online (Sandbox Code Playgroud)
由于不同的组件在每个数组上进行操作,因此不会查看所有数组中的不同组件
python ×2
r ×2
email ×1
enums ×1
forecasting ×1
knitr ×1
mypy ×1
r-markdown ×1
scikit-learn ×1
snowflake-cloud-data-platform ×1
time-series ×1