我是 Typescript 的新手,并陷入了这个问题。所以,我有一个类型定义为:
type MainType = Node & {
id: string;
name: string;
notifications: number
}
Run Code Online (Sandbox Code Playgroud)
我想要一个不包含Node类型的类型。
//Expected type
{
id: string;
name: string;
notifications: number
}
// I tried using Exclude, but it returns never
type SecondaryType = Exclude<MainType, Node>
//I tried using Omit, but that doesn't allow me to pass Node
type SecondaryType = Omit<MainType, Node>
Run Code Online (Sandbox Code Playgroud) 我有一个 DynamoDB 表,其列和主键为ipAddress:
我正在从我的 React 网站获取用户的 IP 地址,并通过 Lambda 函数和 API Gateway POST 请求将其插入到 DynamoDB。
如果来自 React 网站的 IP 地址已经存在于 DynamoDB 中,则增加visits列中的值。如果没有,则使用新的 IP 地址和visits = 1. 我尝试使用ConditionExpression但无济于事。
到目前为止,我只使用 Lambda 插入 ipAddress。下面是我在 NodeJS 中的 Lambda 函数:
const AWS = require("aws-sdk");
const documentClient = new AWS.DynamoDB.DocumentClient();
exports.handler = async event => {
const { ipAddress} = JSON.parse(event.body);
const params = {
TableName: "ipAddress",
Item: {
ipAddress: ipAddress,
}
};
try {
const …Run Code Online (Sandbox Code Playgroud) 我的一个数据框(df1)看起来像:
Col1 Col2 Col3 Col4 Col5
A B C D E
B X Y null null
C E null null null
Run Code Online (Sandbox Code Playgroud)
另一个数据框(df2)看起来像:
Val1 Val2 Val3
A D X
C Y null
B null null
E null null
Run Code Online (Sandbox Code Playgroud)
我想要的最终数据框(最终)是:
Col1 Col2 Col3 Col4 Col5
Val1 Val1 Val1 Val2 Val1
Val1 Val3 Val2 null null
Val1 Val1 null null null
Run Code Online (Sandbox Code Playgroud)
*如果你想知道为什么我有这个奇怪的条件来满足:我想在这里做特色工程.我在df2中手动对df1中的类似功能进行了分组.
比如说,"Python","Java","C",这3个列在"编程"栏目下,
"领导力","沟通","演示",在"软技能"下进行
我有一个数据框,看起来像:
Col1 Col2 Col3 Col4 Col5
A B C D E
B X Y null null
null null null null null
I B W E R
Run Code Online (Sandbox Code Playgroud)
由于第三行具有所有空值,因此我想在第三行中填充一个值.
最终的数据框应如下所示:
Col1 Col2 Col3 Col4 Col5
A B C D E
B X Y null null
xyz null null null null
I B W E R
Run Code Online (Sandbox Code Playgroud)