不要将使用作为正则表达式的日期格式格式的字符串误解。
如果解析的字符串使用“ - ”作为日期组件之间的分离器,这也将有效。
尝试以下操作:
import pandas as pd
dataset = {
'A': [6, 2, 3, 4, 5, 5, 7, 8, 9, 7],
'B': [5, 1, 2, 3, 4, 4, 6, 7, 8, 6],
'C': [0, 1, 0, 1, 1, 0, 1, 0, 1, 0]
}
df = pd.DataFrame(dataset)
print(df)
# this part of code is ok to return muntiple values
def quanta1(data):
return data['A']+data['B'], data['A']-data['B']
a, b = quanta1(df)
print(a)
print(b)
# I want to return two values a and b with the if condition
def quanta2(data):
data = data[data["C"] > 0]
return data['A']+data['B'], data['A']-data['B']
a, b = quanta2(df)
print(a)
print(b)
也许修改了所有这些功能和过程的其他对象(例如,包装规范),并且“无效”了所有引用它的对象。
基本上,您不必做任何事情 - Oracle一旦有人称呼它们,就会自动重新编译它们。
这是一个例子。
带有单个函数的软件包:
SQL> create or replace package pkg_test as
2 function f_test (par_number in number) return number;
3 end;
4 /
Package created.
SQL> create or replace package body pkg_test as
2 function f_test (par_number in number) return number
3 is
4 begin
5 return par_number;
6 end;
7 end;
8 /
Package body created.
独立函数,该函数从包装中引用(呼叫)函数;
SQL> create or replace function f_test_2 (par_number in number)
2 return number
3 is
4 begin
5 return pkg_test.f_test(par_number);
6 end;
7 /
Function created.
它的状态是什么?它是有效的:
SQL> select object_name, object_type, status from user_objects where object_name = 'F_TEST_2';
OBJECT_NAME OBJECT_TYPE STATUS
-------------------- ------------------- -------
F_TEST_2 FUNCTION VALID
它有效吗?是的:
SQL> select f_test_2 (100) result from dual;
RESULT
----------
100
SQL>
好的,现在让我们稍微修改包装函数的规格(我添加default
srause):
SQL> create or replace package pkg_test as
2 function f_test (par_number in number default 0) return number;
3 end;
4 /
Package created.
SQL> create or replace package body pkg_test as
2 function f_test (par_number in number default 0) return number
3 is
4 begin
5 return par_number;
6 end;
7 end;
8 /
Package body created.
我没有修改独立函数f_test_2
。它的状态是什么?它现在无效:
SQL> select object_name, object_type, status from user_objects where object_name = 'F_TEST_2';
OBJECT_NAME OBJECT_TYPE STATUS
-------------------- ------------------- -------
F_TEST_2 FUNCTION INVALID --> see? INVALID
我可以使用它(不重新编译)吗?是的,我可以:
SQL> select f_test_2 (500) result from dual;
RESULT
----------
500
SQL>
这是您答案的示例代码:
html:
<p id="ANYTHING_YOU_WANT">ANYTHING_YOU_WANT</p>
js:
const VARIABLE_NAME = document.getElementById("ANYTHING_YOU_WANT");
VARIABLE_NAME.style.color = "aqua";
给您的课程和文本,而不是 nothing_you_want 和您的变量名称,而不是
您不必担心它。一个线程读数和一个线程编写将按照您的预期工作。插座是完整的双链体,因此您可以在写作时阅读,反之亦然。您必须担心是否有多个作家,但事实并非如此。
最流利的方式:
Model::query()->whereNotIn('column', $arrayOfValues);
我建议您始终将Query()方法与模型一起使用,因为它可以探索Laravel模型类的所有可用选项
好的,我仍然不了解certbot启动自己的nginx,不停止它,弄乱pids的怪异,所有这些...但是certbot现在可以看到我们的服务器并续订SSL证书。经过两天的宣誓盲人,它并没有被防火墙规则阻止……那是防火墙。
叹。
需要一点澄清条件应将一排从DF2合并为DF1,以及合并的外观。
该代码段可以按照我的条件来完成我认为您正在寻找的操作,但是我只是在DF1中添加了一个Col,该Col跟踪DF1的Col与DF2中的一些行相匹配,以及DF2
df1 = pd.DataFrame(data_1)
df2 = pd.DataFrame(data_2)
check = []
for df1_ind in df1.index:
found = ""
for df2_ind in df2.index:
col1_check = df1["Col1_df1"][df1_ind] in df2["To_Check"][df2_ind]
col2_check = df1["Col2_df1"][df1_ind] in df2["To_Check"][df2_ind]
df1_id_present = df1["df1_ID"][df1_ind] in [df2['df2_ID1'][df2_ind], df2['df2_ID2'][df2_ind]]
# wasn't sure if that first conditional meant the df1_id being present effected the column checks
if col1_check:
found += f"Col_1_present(df2_ID={df2_ind})::"
if col2_check:
found += f"Col_2_present(df2_ID={df2_ind})::"
if not found == "":
# this means the cols from df1 we are looking for in df2 were found at some row.
# leave the inner for loop and save these results
# unless you expect the row contents to appear in multiple rows of df2
break
if found == "":
found = "false"
check.append(found)
df1['Checks'] = check
print(df1.head())
输出 的该行的ID :
df1_ID Col1_df1 Col2_df1 Col3_df1 Checks
0 ABC-001 a.102_103i k159* Test1 Col_1_present:(df2_ID=0)::
1 DEF-002 a.36-89E k188 Test2 Col_2_present:
2 GHI-003 ab.23<<X e542m Test3 Col_1_present:
这是我组合的“级联选择”的演示系统,以回答另一个网站上的类似问题。
演示页面:
@page "/Test"
@page "/"
<PageTitle>Index</PageTitle>
<h6>Select Test</h6>
<div class="m-2 p-2 row">
<div class="col-2">
Continent:
</div>
<div class="col-6">
<select class="form-select form-select-sm" value="@model.Continent" @onchange=this.ContinentChange>
<option value="">-- Select A Continent --</option>
@foreach (var continent in Data.Continents)
{
<option value="@continent.Name">@continent.Name</option>
}
</select>
</div>
</div>
<div class="m-2 p-2 row">
<div class="col-2">
Country:
</div>
<div class="col-6">
<select disabled="@this.countryDisabled" class="form-select form-select-sm" value="@model.Country" @onchange=this.CountryChange>
<option value="">-- Select A Country --</option>
@foreach (var item in filteredCountries)
{
<option value="@item.Name">@item.Name</option>
}
</select>
</div>
</div>
<div class="m-2 p-2 bg-light">
<div>
Continent = @model.Continent
</div>
<div>
Country = @model.Country
</div>
</div>
@code {
private CountryData Data = CountryData.Instance();
private Model model = new Model();
private List<Country> filteredCountries = new List<Country>();
private bool countryDisabled => string.IsNullOrWhiteSpace(this.model.Continent);
private void ContinentChange(ChangeEventArgs e)
{
string continent = e.Value?.ToString() ?? string.Empty;
if (!model.Continent.Equals(continent, StringComparison.CurrentCultureIgnoreCase))
{
filteredCountries.Clear();
filteredCountries.AddRange(Data.Countries.Where(item => item.Continent == continent));
model.Country = string.Empty;
model.Continent = continent;
}
}
private void CountryChange(ChangeEventArgs e)
{
string country = e.Value?.ToString() ?? string.Empty;
if (!model.Country.Equals(country, StringComparison.CurrentCultureIgnoreCase))
model.Country = country;
}
public class Model
{
public string Country { get; set; } = string.Empty;
public string Continent { get; set; } = string.Empty;
}
}
及其使用的数据集。
namespace BlazorApp3.Data;
public class Continent
{
public string Name { get; set; } = String.Empty;
}
public class Country
{
public string Continent { get; set; } = string.Empty;
public string Name { get; set; } = String.Empty;
}
public class CountryData
{
public IEnumerable<Country> Countries { get; private set; } = Enumerable.Empty<Country>();
public IEnumerable<Continent> Continents { get; private set; } = Enumerable.Empty<Continent>();
private CountryData()
=> this.GetData();
public void GetData()
{
var continents = new List<Continent>();
var continent = new Continent { Name = "Europe" };
continents.Add(continent);
var countries = new List<Country>
{
new Country { Name = "France", Continent = continent.Name },
new Country { Name = "Portugal", Continent = continent.Name },
new Country { Name = "England", Continent = continent.Name },
};
continent = new Continent { Name = "Africa" };
continents.Add(continent);
countries.Add(new Country { Name = "Senegal", Continent = continent.Name });
countries.Add(new Country { Name = "Egypt", Continent = continent.Name });
countries.Add(new Country { Name = "Kenya", Continent = continent.Name });
continent = new Continent {Name = "South America" };
continents.Add(continent);
countries.Add(new Country { Name = "Brazil", Continent = continent.Name });
countries.Add(new Country { Name = "Chile", Continent = continent.Name });
countries.Add(new Country { Name = "Peru", Continent = continent.Name });
this.Continents = continents;
this.Countries = countries;
}
public static CountryData? _instance;
public static CountryData Instance()
{
if (_instance is null)
_instance = new CountryData();
return _instance;
}
}
以下两个选项可用。
- 列表生成
mylist = [1, 2, 7, 11, 8, 55, 89, 1, 3, 8]
res = [mylist[i:i+5] for i in range(0, len(mylist)-4)]
- 循环,因为它是顺序构造的,并且一旦不满足长度,就可以简单地退出循环(另请参见以前的方法,以限制循环长度的限制)
mylist = [1, 2, 7, 11, 8, 55, 89, 1, 3, 8]
new = []
for i in range(0, len(mylist)):
if len(mylist[i:i+5]) == 5:
new.append(mylist[i:i+5])
else:
break
如果打算在中间件调用中访问服务,则无需尝试访问
serviceCollection
在启动寄存器寄存器外部使用中间件中的延期工厂委托所需的暂时服务,
可以通过方法注入明确注入服务
中间件的
InvokeAsync
的其他参数,httpcontext
由依赖项注入填充(di)。进而注入会员时,这将解决您的瞬态服务
If intending to access the service within the middleware invoke then there is no need to try and access
ServiceCollection
outside of Startupregister desired transient service using deferred factory delegate
In the middleware the service can be explicitly injected via method injection
Additional parameters for the middleware's
InvokeAsync
, afterHttpContext
are populated by dependency injection (DI).This will in turn resolve your transient service when injecting into the member
您可以在中间件中创建瞬态DI服务吗?