library(data.table)
df <- data.frame(
ID = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L),
year = c(2000L,2001L,2002L,2003L,2004L,
2000L,2001L,2002L,2003L,2004L),
level = c(NA, 3L, 3L, 2L, 1L, 1L, 1L, 1L, 1L, 1L)
)
setDT(df)[!is.na(level), level := cummin(level), by = ID][]
#> ID year level
#> 1: 1 2000 NA
#> 2: 1 2001 3
#> 3: 1 2002 3
#> 4: 1 2003 2
#> 5: 1 2004 1
#> 6: 2 2000 1
#> 7: 2 2001 1
#> 8: 2 2002 1
#> 9: 2 2003 1
#> 10: 2 2004 1
由
我不知道您的群体Joine目的是什么?我没有实体,从我可以重写的示例中:
var products = customerProductPrices.Select(pp => new ProductFilterResultModel
{
Id = pp.Product.Id,
Price = pp != null ? pp.Price : 0
})
不确定是否有其他原因使用上下文将此数据获取到API消费者中,但是使用NextJ, getStaticProps
或 getserversideprops
当然要馈入路由组件,但是也许您错过了以下细节?
组件道具是活动页面,因此,每当您在路由之间导航时,组件都会更改为新页面。 因此,您发送给组件的任何道具将由页面 。
收到
pageProps
是一个对象,其初始道具通过我们的数据获取方法预先加载了您的页面,否则是一个空的对象。
https://nextjs.org/docs/advanced-fanced-features/custom-custom-app
因此, _app.tsx
可以在您的路由组件中采取任何行动,通常会从 getStaticProps
或 getServersideProps
types.ts
// or whatever union type you need to indicate that myriad of "custom datas" you might be pushing out of getStaticProps
export type MaybeCustomDataFromGetStaticProps = Map<string, string> | undefined;
export type PagePropsWithCustomData = {
customData: MaybeCustomDataFromGetStaticProps
isSSR?: boolean;
}
pages/_app.tsx
import type { PagePropsWithCustomData } from '../types';
const App = ({
Component,
pageProps: { customData, isSSR, ...pageProps},
router,
}: AppProps<PagePropsWithCustomData & Record<string, unknown>>) => {
return (
<ContextProvider value={{ isSSR, customData }}>
<ContextApiConsumingComponent />
<Component {...pageProps} />
</ContextProvider>
)
}
pages/somepage.tsx
import type { NextPage, GetServerSideProps } from "next";
import type { PagePropsWithCustomData } from '../types';
import { magicallyGetCustomData } from '../services/Api';
import { isSSR } from '../core/Routing';
type IndexRouteProps = PagePropsWithCustomData & {
isSSR?: boolean;
}
const IndexRoute:NextPage<IndexRouteProps> = ({ customData, isSSR }) => {
// no longer need to do anything with customData, or isSSR here
return (
<div>stuff</div>
);
}
export const getServerSideProps:GetServerSideProps<IndexRouteProps> = async (context) => {
const customData = await magicallyGetCustomData();
return {
props: { customData , isSSR: isSSR(context) }
};
};
export default IndexRoute
我不太确定您想做什么,但是根据我所理解的内容,这是一个解决方案:
从我看到的数据框架中,您的数据框架有多个列,您希望将其分组为一列,并将其分组为具有最高值的值最低,因此我将创建一个与以下特征几乎相同的数据框架:
import pandas as pd
import numpy as np
cols = 3
rows = 4
np.random.seed(0)
df = pd.DataFrame(np.random.randint(0, 1000, (rows, cols)), columns= ["A","B","C"])
print(df)
A B C
0 684 559 629
1 192 835 763
2 707 359 9
3 723 277 754
现在,我将单行中的所有列对它们进行分组,并以这样的降序组织它们:
data = df.to_numpy().flatten()
data = pd.DataFrame(data)
data.sort_values(by=[0],ascending=False)
因此,我们将获得1倍矩阵,其中值在降序:
0
4 835
5 763
11 754
9 723
6 707
0 684
2 629
1 559
7 359
10 277
3 192
8 9
注意:此代码片段应适用于您的脚本;我没有这样做,因为我不知道您的数据集,最后我的英语对任何语法错误都不是很抱歉
检查柏树测试,并具有一些轻微的文件夹路径和不同的baseurl的mod。
由于赛普拉斯V10不再具有“运行所有”选项,因此我还添加了一个称为 all.cy.js 的枪管规格,该规格允许运行多个规格,并且 也可以执行规格的顺序(这对此很重要)。
该测试在 cypress Open
中均可正常工作,然后选择 all.cy.js
,以及 cypress run-spec cypress/e2e/e2e/all.cy.js
。
all.cy.js
import './site.cy.js'
import './another.cy.js'
site.cy.js
let dataStore = require("../support/dataStore");
import "cypress-localstorage-commands";
describe('Verify the Global data saving', () => {
context('Global data', () => {
beforeEach(() => {
cy.restoreLocalStorage();
cy.visit('http://example.com')
});
it('First get the text and Save globally', () => {
// cy.get('#companyNameDiv > span').invoke('text').then((text)=>{
const text = 'this is my text'
dataStore.globaldata = text;
console.log("First test outcome:: " +dataStore.globaldata); // all good here
// });
});
it('Use that text in second test', () => {
console.log("Yeh, global text in second test :: " +dataStore.globaldata ); // all good here
});
});
});
entere.cy.js
let dataStore = require("../support/dataStore");
import "cypress-localstorage-commands";
describe('Retrive another test file', () => {
context('Retrive saved data in another test file', () => {
it('Get the text', () => {
console.log("Yeh, another test file:: " +dataStore.globaldata);
expect(dataStore.globaldata).to.eq('this is my text') // ✅ passes
});
});
});
经过帖子之后,人们也遇到了这个问题,我查看了学科支持的答案,他们都说访问这些文档,我以前曾多次看过这些文档。但是,这一次我向下滚动并找到了一个“缩写”,因为他们称其为uid:
< img src =“ https://i.sstatic.net/grolm.png” alt =“ Schoology api docs”>
所以而不是尝试使用用户/ME
端点您只需使用端点:/app-user-info
,它返回带有时间戳和uid的JSON!
获得UID后,您可以通过使用UID替换我的 uders/me 端点来自由:用户/{uid}
url:
https://api.schoology.com/v1/app-user-info
两腿授权标头:
OAuth realm="Schoology API",
oauth_consumer_key="{CONSUMER_KEY}",
oauth_signature_method="PLAINTEXT",
oauth_timestamp="{TIMESTAMP}",
oauth_token="",
oauth_nonce="{RANDOM_CHARS}",
oauth_version="1.0",
oauth_signature="{CONSUMER_SECRET}%26"
最后,我自己修改了以下几乎没有修改,我自己解决了问题。
初始化 formControlname
喜欢 myDivName:this.fb.Array([]),
get myDivName() {
return <FormArray>this.myTestForm.get('myDivName');
}
ins drop> drop()方法>分配并传递formValue
const formArry = this.myDivName;
formArry.insert(0,this.fb.control(event.container.data));
注意:我不确定修复的效率有多高,但会尽可能地优化它
。
您可以尝试将其转换为字符串,然后使用Regexp提取所需的小数
function truncDigits(inputNumber: number, digits: number) {
const match = inputNumber.toString().match(new RegExp(`^\\d+\\.[\\d]{0,${digits}}`))
if (!match) {
return inputNumber
}
return parseFloat(match[0])
}
:我使用的是 Regexp
ctor的字符串版本,因为字面意义不允许动态参数。
如果要在&gt;
元素中选择&lt; svg&gt;
之前,请尝试以下XPath:
//*[@data-component-id="nokia-react-components-iconbutton" and following-sibling::svg[1][contains(@class,"HelpOutline")]]
在使用可观察到
时,您需要了解,您不能依靠 async/等待
来考虑完成测试。因此,您可以使用完成
参数为您处理。
在您的示例中,您需要在 get
函数的模拟实现中返回可观察的
,并且在该可观察到的
中,您应该丢下错误。
您可以在查询中应用多种方式。
VesselProductDetails::where('vessel_code',$vessel_code)
->orderBy('vessel_code', 'asc')
->orderBy('type', 'asc')
->get();
希望这对您有用。
您应该使用 textContent
而不是 innertext
。
这是我的解决方案:
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const jsdom = require('jsdom');
const { JSDOM } = jsdom;
class Appartment {
price
title
description
location
}
let multipleDivs = []
const appartments = []
function trim(text){
return text.replace(/(\r\n|\n|\r)/gm, "").trim()
}
async function fetchKijijiAppartments() {
const url = `https://www.kijiji.ca/b-ville-de-montreal/appartement-4-1-2/k0l1700281?rb=true&dc=true`
try {
const kijijiRes = await fetch(url);
if (!kijijiRes.ok) {
throw new Error(
`HTTP error: ${kijijiRes.status}`
)
}
const response = await kijijiRes.text()
// console.log("DB: ", response)
const dom = new JSDOM(response)
multipleDivs = dom.window.document.querySelectorAll(".info-container")
//console.log("DB: " multipleDivs)
return multipleDivs
} catch (error) {
console.log("Error Made")
console.log(error)
}
}
async function scrapeAppartments() {
await fetchKijijiAppartments()
.then(data => {
data.forEach(div => {
const appartement = new Appartment
appartement.price = trim(div.querySelector(".price").textContent)
appartement.title = trim(div.querySelector(".title").textContent)
appartement.description = trim(div.querySelector(".description").textContent)
console.log("DB: ", appartement)
appartments.push(appartement)
})
})
}
scrapeAppartments()
您可以通过一定程度的间接解决这个问题。
只要只有一位作者,您就可以这样做:
- 将一组数据项放在结构中,
- 分配几个这样的结构
- 在非原子上写入读者没有使用原子上的读者
- 将指针更改为读者应使用读取器的结构
应读取指针,然后访问各个结构中的数据。
如果可能在主要上下文仍在阅读时发生另一个中断,那么您需要将指针保留到读取器所使用的struct的指针,而作者可以在填写结构之前对此进行检查。如果只有一位读者,那么在原子上访问第二个指针会更容易。
为了使事情变得平滑,您可以分配三个或更多的结构,并将它们视为环缓冲区。
这个问题有点旧了,但是您可以。
此链接说您需要有一个有效的NGROK配置文件(带有验证令牌和所有定义的隧道),然后运行以下命令:
并指向保存配置文件的位置。
然后,您可以使用ngrok命令启动,停止,重新启动和卸载服务。
我今天只是这样做了,它运行良好。
希望这会有所帮助。
This question is a bit old, but you can install Ngrok as a Windows service.
This link says you need to have a valid Ngrok config file (with your auth token and all your tunnels defined) and then run the following command:
and point to where you've saved your config file.
Then you can use Ngrok commands to start, stop, restart, and uninstall your service.
I just did this today and it is working pretty well.
Hope this helps.
在后台运行NGrok