您可以使用将 NAN
更改为 0
:
import pandas as pd
import numpy as np
# for column
df['column'] = df['column'].replace(np.nan, 0)
# for whole dataframe
df = df.replace(np.nan, 0)
# inplace
df.replace(np.nan, 0, inplace=True)
如果您仔细查看OUPUT,您将意识到您在任务级别(您已经使用的键),但也可以在结果
上。这是您想在循环中考虑到的东西。
知道这一点,您首先必须摆脱两个条件,因为任务本身的失败状态不会以任务项目的状态为前提。它只是给您一个普遍的指示,表明至少有一个元素失败。
{%{%{%{%}
{% for result in server_port_check.results if result.failed %}
{% for result in server_port_check.results if not result.failed %}
然后,您可以对... 。 x/templates/#jinja-filters.select“ rel =” nofollow noreferrer“> sélect
filter 以及 失败
succe> succes> success> succes> Succe> Success 测试
{% for result in server_port_check.results | select("failed") %}
{% for result in server_port_check.results | select("success") %}
使用您的数据,模板:
Port Checks:
{% for result in server_port_check.results | select("failed") %}
{%- if loop.first -%}
The following ports are not open:
{%- endif %}
Host: {{ result.item.name }}
Port: {{ result.item.port }}
{% endfor %}
{% for result in server_port_check.results | select("success") %}
{%- if loop.first -%}
The following ports are open:
{%- endif %}
Host: {{ result.item.name }}
Port: {{ result.item.port }}
{% endfor %}
将渲染在:
Port Checks:
The following ports are not open:
Host: salt
Port: 4505
The following ports are open:
Host: dc.com
Port: 636
不确定是否可以在sentry UI中过滤,但是您肯定会根据 sentryappender 它将仅在达到某些阈值时衡量事件并发射事件。
一个选项是用 na
替换0,然后使用 fill
library(dplyr)
library(tidyr)
DF1 %>%
mutate(New = na_if(New, 0)) %>%
group_by(Group) %>%
fill(New) %>%
ungroup %>%
mutate(New = replace_na(New, 0))
-Output
# A tibble: 15 × 3
Date Group New
<chr> <int> <int>
1 2021-04-20 1001 0
2 2021-04-21 1001 0
3 2021-04-22 1001 9
4 2021-04-23 1001 9
5 2021-04-24 1001 9
6 2021-04-25 1001 12
7 2021-04-26 1001 12
8 2021-04-27 1001 12
9 2021-04-28 1001 12
10 2021-04-20 1002 0
11 2021-04-22 1002 1
12 2021-04-23 1002 1
13 2021-04-24 1002 1
14 2021-04-25 1002 3
15 2021-04-26 1002 3
如果已订购了这些值,则可以使用 Cummax
DF1 %>%
group_by(Group) %>%
mutate(New = cummax(New)) %>%
ungroup
-Output
# A tibble: 15 × 3
Date Group New
<chr> <int> <int>
1 2021-04-20 1001 0
2 2021-04-21 1001 0
3 2021-04-22 1001 9
4 2021-04-23 1001 9
5 2021-04-24 1001 9
6 2021-04-25 1001 12
7 2021-04-26 1001 12
8 2021-04-27 1001 12
9 2021-04-28 1001 12
10 2021-04-20 1002 0
11 2021-04-22 1002 1
12 2021-04-23 1002 1
13 2021-04-24 1002 1
14 2021-04-25 1002 3
15 2021-04-26 1002 3
数据
DF1 <- structure(list(Date = c("2021-04-20", "2021-04-21", "2021-04-22",
"2021-04-23", "2021-04-24", "2021-04-25", "2021-04-26", "2021-04-27",
"2021-04-28", "2021-04-20", "2021-04-22", "2021-04-23", "2021-04-24",
"2021-04-25", "2021-04-26"), Group = c(1001L, 1001L, 1001L, 1001L,
1001L, 1001L, 1001L, 1001L, 1001L, 1002L, 1002L, 1002L, 1002L,
1002L, 1002L), New = c(0L, 0L, 9L, 0L, 0L, 12L, 0L, 0L, 0L, 0L,
1L, 0L, 0L, 3L, 0L)), class = "data.frame", row.names = c(NA,
-15L))
使用 pattern properties
而不是属性
。在下面的示例中,模式匹配正则。*
接受任何属性名称,我允许仅使用 string> string
string null 的类型>“额外properties”:false 。
"patternProperties": {
"^.*$": {
"anyOf": [
{"type": "string"},
{"type": "null"}
]
}
},
"additionalProperties": false
...或者,如果您只想在“对象”中允许字符串(例如原始问题中):
{
"patternProperties": {
"^.*$": {
"type": "string",
}
},
"additionalProperties": false
}
如果您的班级应该具有相同的行为,那么使用多晶型术变得非常简单。该模式称为策略。让我举个例子。
首先,我们需要使用 enum
。如果您没有 enum
,则可以创建一个方法,该方法将根据您的条件返回枚举值:
if (receipt.getType().equals(X) && receipt.getRegion.equals(EMEA)) // other
// code is omitted for the brevity
So enum
将看起来像这样:
public enum ReceiptType
{
Emea, Y, Apac
}
然后我们需要一个抽象类这将描述派生类的行为:
public abstract class ActionReceipt
{
public abstract string Do();
}
我们的派生类将看起来以下方式:
public class ActionReceiptEmea : ActionReceipt
{
public override string Do()
{
return "I am Emea";
}
}
public class ActionReceiptY : ActionReceipt
{
public override string Do()
{
return "I am Y";
}
}
public class ActionReceiptApac : ActionReceipt
{
public override string Do()
{
return "I am Apac";
}
}
此外,我们需要一个工厂,该工厂将基于枚举创建派生的类。因此,我们可以使用 factory模式 进行稍作修改:
public class ActionReceiptFactory
{
private Dictionary<ReceiptType, ActionReceipt> _actionReceiptByType =
new Dictionary<ReceiptType, ActionReceipt>
{
{
ReceiptType.Apac, new ActionReceiptApac()
},
{
ReceiptType.Emea, new ActionReceiptEmea()
},
{
ReceiptType.Y, new ActionReceiptY()
}
};
public ActionReceipt GetInstanceByReceiptType(ReceiptType receiptType) =>
_actionReceiptByType[receiptType];
}
然后在行动中看起来会进行多种态度。这样:
void DoSomething(ReceiptType receiptType)
{
ActionReceiptFactory actionReceiptFactory = new ActionReceiptFactory();
ActionReceipt receipt =
actionReceiptFactory.GetInstanceByReceiptType(receiptType);
string someDoing = receipt.Do(); // Output: "I am Emea"
}
更新:
您可以创建一些辅助方法,该方法将返回 enum
基于基于
您的区域逻辑
和 recepiptType
:
public class ReceiptTypeHelper
{
public ReceiptType Get(ActionReceipt actionReceipt)
{
if (actionReceipt.GetType().Equals("Emea"))
return ReceiptType.Emea;
else if (actionReceipt.GetType().Equals("Y"))
return ReceiptType.Y;
return ReceiptType.Apac;
}
}
您可以这样称呼:
void DoSomething()
{
ReceiptTypeHelper receiptTypeHelper = new ReceiptTypeHelper();
ReceiptType receiptType = receiptTypeHelper
.Get(new ActionReceiptEmea());
ActionReceiptFactory actionReceiptFactory = new
ActionReceiptFactory();
ActionReceipt receipt =
actionReceiptFactory.GetInstanceByReceiptType(receiptType);
string someDoing = receipt.Do(); // Output: "I am Emea"
}
事实证明,您可以访问容器并列出blobs+dirs,但是您无法在没有异常的情况下检查容器是否存在。我从来没有想过要尝试此操作,因为我现有的代码正在使用以确保用户选择了一个合适的容器
这样 - 尝试和测试
let data=[
{ "positive": 2, "negative": 4 },
{ "positive": 9, "negative": 18 },
{ "positive": 6, "negative": 12 }
];
let new_d=[]
data.map((e,i,a)=>{Object.keys(e).map((e1,i1,a1)=>{new_d[e1]=[...new_d[e1]||[],e[e1]]})})
console.log(new_d)
您应该在 JSX
元素中设置电子邮件
属性:
function App() {
const [count, setCount] = useState(null);
function getFormData(e) {
e.preventDefault();
console.log(count);
}
return (
<div className='App'>
<form onSubmit={getFormData}>
<select onChange={(e) => setCount(e.target.value)}>
<option>select option</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
<button type='submit'>submit</button>
</form>
<Ternaryi email='hyy' name={count} />
</div>
);
}
export default App;
使用 tolocalestring()
方法将时间格式更改为24小时,例如 date.toleocalestring('en-us',{hour12:false})
。 TOLOCALESTRING
方法返回一个按照提供的语言环境和选项参数表示日期和时间的字符串。
const date = new Date();
console.log(
date.toLocaleString('en-US', {
hour12: false,
}),
);
library(data.table)
# set as data table if yours isn't one already
setDT(df)
# dummy data
df <- data.table(driver = c("Driver A", "Driver A", "Driver A", "Driver B", "Driver B", "Driver B")
, points = c(1,5,7,3,5,8)
); df
# calculate cumulative sum and date (assumes data sorted in ascending date already)
df[, `:=` (cum_sum = cumsum(points)
, date = 1:.N
)
, driver
]
# plot
ggplot(data=df, aes(x=date, y=cum_sum, group=driver)) +
geom_line(aes(linetype=driver)) +
geom_point()
请注意,如果我们有很多驱动程序(杂乱的地块),则按照我们目前的操作绘制一条线可能不是最佳的
.booking-row {
background: url('https://i.sstatic.net/rVSVL.png') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
您需要更新加入条件,以包括日期过滤器并将其从Where子句中删除。为简单起见,我已重命名了表格和列名。 这是sqlfiddle
SELECT p.id,
COUNT(DISTINCT(a.id)) AS documentA_total,
COUNT(DISTINCT(b.id)) AS documentB_total
FROM project p
LEFT JOIN docA a ON p.id = a.project_id and a.created_at BETWEEN '2022-01-01' AND '2022-03-31'
LEFT JOIN docB b ON p.id = b.project_id and b.created_at BETWEEN '2022-01-01' AND '2022-03-31'
GROUP BY p.id;
我已重命名为“表和列”名称,以实现简单性。您的确切查询将类似于以下查询,
SELECT "project"."id",
COUNT(DISTINCT(documenta.id)) AS documentA_total
COUNT(DISTINCT(documentb.id)) AS documentB_total,
FROM project
LEFT JOIN documenta ON documenta.projectid = project.id and "documenta"."createdAt" BETWEEN '{{daterange.start}}' AND '{{daterange.end}}'
LEFT JOIN documentb ON documentb.projectid = project.id and "documentb"."createdAt" BETWEEN '{{daterange.start}}' AND '{{daterange.end}}'
GROUP BY project.id;
可以使用Extension 代码跑步者通过快捷键在右上角的play图标运行代码: ctrl ++ alt ++ n 并流产 ctrl + alt + m 。但是默认情况下,它仅显示程序的输出,但要接收输入,您需要遵循一些步骤:
ctrl +, ,然后打开设置菜单,扩展名&gt; run代码配置滚动向下滚动其属性和属性和在设置中查找编辑单击它,然后添加以下代码INSITE:
{
"code-runner.runInTerminal": true
}
您可以使用
isin
:设置
You can use
isin
:Setup
熊猫映射两个数据框之间的列