所有问题

0 投票
1 回答
1633 浏览

apache-spark - 通过一列中的唯一值随机拆分 DataFrame

我有一个 pyspark DataFrame,如下所示:

每行有一个groupId,多行可以有相同的groupId

我想将这些数据随机分成两个数据集。但是所有具有特定属性的数据都groupId必须在其中一个拆分中。

这意味着 if d1.groupId = d2.groupId、 thend1d2都在同一个拆分中。

例如:

在 PySpark 上做这件事的好方法是什么?我可以randomSplit以某种方式使用该方法吗?

0 投票
1 回答
41 浏览

mysql - MYSQL - Group Contact rows with records NOT IN

My case looks simple but i'm messing around with this..

I have 4 tables: User, Macros, Categories, and another one that relate users with categories. One Macro have many Categories.

What i need, is a query that based on the Macro, get the users and the Categories where user is NOT IN.

Example: I have a macro named VEICULES, with categories CAR,TRUCK and Motorcycle. User José is on category CAR and User Julio on category CAR and TRUCK, so my query should return:

Tables: prd_users

cat_macros

cat_categories

prd_tr_rabbit_catg

I'm stucked on just getting the categories where the user already is ..

0 投票
0 回答
35 浏览

php - php -> 定时 bash 脚本总是关闭

我有这个愚蠢但不完美但可以工作的 Bash 脚本

这永远不会关闭,因为它会在执行其他脚本时执行,当我在终端中启动它时脚本工作正常。但由于我想控制一个网站(不同的时间/开始/停止),我需要通过 php 执行它。我的PHP代码:

这只是一个不好的方法吗?甚至可以运行一个永远不会关闭的 bash 脚本吗?

因为现在脚本开始但在 5 秒后关闭我也尝试使用 nohub 但结果相同

在树莓派上运行 apache2

0 投票
1 回答
154 浏览

swift - 快速将可测试代码与静态方法调度相结合

最近我阅读了很多关于 Swift 运行时的内容,并且对使用静态方法调度优化我的代码越来越感兴趣。这发生在以下方法中:

  • 结构方法
  • final 类方法,即用 final 关键字声明为私有或在 final 类中
  • 在协议扩展中定义的协议方法,而不在协议本身中声明。

问题是,这些情况都不能让我编写可测试的代码,至少不是我现在这样做的方式:在单元测试中注入被模拟替换的协议实体。

那么,是否有可能在不放弃静态方法分派的情况下编写可测试的代码,如果可以,如何去做呢?

谢谢!

0 投票
2 回答
88 浏览

excel - Excel AVERAGEIFS looking up ONE of the criteria columns

I have built a large data set and I need to see the average results given many different criteria. I've done this with the AVERAGEIFS function and it works just fine, however the more and more I add its getting really time intensive.

I'm wondering if there is a way to nest a vlookup or index match or anything like that in the AVERAGEIFS that read the criteria column heading and criteria in a cell (or 2 if they need to be separated) to be added to the AVERAGEIFS.

Here is an example of my spreadsheet: enter image description here

The first 3 sets of criteria I want to stay locked.

I want it to read what the 4th criteria column and criteria should be by referencing the I11 cell. The highlighted portion in the formula bar is the part that I want to reference I11 so it reads it and knows that the 4th criteria is the 'code' column and the criteria is '>7'. I can separate this into 2 separate cells if need be.

I've tried a few combinations of VLOOKUP and INDEX MATCH but cannot get it to work.

Data as Text:

0 投票
1 回答
309 浏览

javascript - 数据绑定按键事件在 div 上不起作用

所以我最近遇到了这个问题。

目标是使用回车键打开选定的行,也可以使用箭头上下移动。为了打开 selected div ,我需要将 selected 的名称传递给启动它的函数。因此,检测目标元素很重要。

在此处输入图像描述

项目使用 Knockout js,所以我有这样的代码:

哪个工作正常,确实会触发 prodItem_onClick 和 btnStartPopup_onClick。

现在我需要一个捕获按键的事件处理程序。所以我继续做同样的事情并添加另一个事件处理程序。

现在奇怪的事情开始发生。首先,它不会触发 moveList 函数。我试过'a'标签,它也没有工作。但是它在输入事件上工作正常。但我需要它在一个有两行且不是输入类型的 div 上工作。

我也尝试使用 jQuery 捕获按键事件,这里的问题是我无法获取目标元素。我得到了整个容器 div 的 html。

任何想法如何解决这个问题?

0 投票
0 回答
478 浏览

elasticsearch - 如何从 Elastic Search 中的日志文件中获取总执行时间?

我有一个作业执行的日志文件,每行都有时间。例如:

我已将整个文件放在 LOGS 字段中(索引)。

现在我想要执行这项工作所花费的总时间。

我怎样才能做到这一点?

0 投票
1 回答
673 浏览

kubernetes - Kubernetes 构建集群时出错,找不到实用程序子网

为什么当我尝试更新新的 Kubernetes 集群时会出现以下错误:

我还不能将它部署到 aws 中。它只在 s3 中创建配置。

另外因为我有私有子网和公共子网,所以我手动更新 k8s 配置以指向正确的子网 ID。例如:ID 是手动添加的。

subnets: - cidr: 10.0.0.0/19 id: subnet-3724bb40 name: us-east-1b type: Private zone: us-east-1b - cidr: 10.0.64.0/19 id: subnet-918a35c8 name: us-east-1c type: Private zone: us-east-1c - cidr: 10.0.32.0/20 id: subnet-4824bb3f name: utility-us-east-1b type: Public zone: us-east-1b - cidr: 10.0.96.0/20 id: subnet-908a35c9 name: utility-us-east-1c type: Public zone: us-east-1c

同样有趣的是,我没有改变我的配置。但是当我一次又一次地运行 kops update 时,我得到了两个不同的结果。这怎么可能?

kops update cluster --name $n error building tasks: could not find utility subnet in zone: "us-east-1c"

然后这个

kops update cluster --name $n error building tasks: could not find utility subnet in zone: "us-east-1b"

0 投票
1 回答
268 浏览

cordova - 流星中的 CORS 与 Cordova

我荒谬地试图让 CORS 在 Meteor 1.8 上工作,突然在我的应用程序中遇到了这个问题:

" I chromium: [INFO:CONSOLE(0)] "访问 XMLHttpRequest 在 ' http://192.168.1.14/sockjs/info?cb=3lc2_ftamu ' 从源 ' http://localhost:12368 ' 已被 CORS 阻止策略:请求的资源上不存在“Access-Control-Allow-Origin”标头。”,来源:http://localhost:12368/ (0)”

它仅出现在 Android 和 iOS 上,而不是仅在运行 Web 时出现。

我搜索了所有堆栈溢出和 Meteor 帮助和论坛,尝试:

在 mobile_config.js 中也试过:

我还尝试了服务器上的其他标头,更新了 Meteor,尝试使用cors 包

以及 Meteor Cordova 不运行时的所有其他常见情况。

任何想法?

0 投票
1 回答
64 浏览

mongodb - MongoDB:按两个字段索引的最快方法?

我使用 MongoDB 作为游戏服务器网络的数据库。网络上的每个玩家都有两种识别他们的方式:他们的用户名和他们的 UUID。这两个字段对于每个玩家都是唯一的,并且根据玩家的姓名检索玩家的 UUID、根据他们的 UUID 检索他们的姓名以及根据他们的姓名或他们的 UUID 检索整个文档通常很有用。在不考虑空间要求的情况下,哪种索引方案可以让这些查询以最快的速度运行?

我的想法是为这两个字段中的每一个创建一个唯一索引,但我很好奇 MongoDB 是否提供了更好的优化,尤其是当我只想检索一个给定另一个字段时。我读过复合索引可以允许覆盖查询,其中不需要检索完整的文档,但我不确定与每个字段都有一个索引相比,这是否会降低性能。

0 投票
1 回答
51 浏览

python - How do I set optional arguments?

please help, I have this function in my code, that would be a module in the future. I haven't done modules so far, but I would like to allow users to change match boolean to False, but I don't want to force them to fill it in case they want to keep it True So I would be happy if there is only 1 input necessary but second ( match = False) optional. It's module that returns postal codes or city names based on postal code dictionary.

0 投票
1 回答
87 浏览

c# - ElasticSearch C# NEST - scriptscorefunction 不起作用

我正在尝试编写一个脚本评分函数来提升仅属于一个类别的项目。

下面的代码似乎不起作用。我从 API 收到“错误响应代码”。我究竟做错了什么?

0 投票
2 回答
457 浏览

arrays - KSH 验证列表中是否存在数字

我有一个数字列表,大约 200,在我的 ksh 开头,我想验证参数 1 是否是这些数字之一。

我用一个很大的 if 解决了这个问题,但我认为必须存在一个更优雅的解决方案。

例如,像这样,但在 ksh

有什么想法开始工作吗?

谢谢。

路易斯

0 投票
2 回答
542 浏览

matlab - 打印时生成特定尺寸的棋盘图案

我试图在 MATLAB 中生成棋盘图案,这样当它打印在美国信纸大小的纸上时,每个框的宽度将为 30 毫米。

我试图更改gcf诸如'Units'等的各种属性'PaperSize',但 PDF 没有按需要打印。

我遇到了其他几种在线方法来生成我需要的东西,但我想在 MATLAB 中生成一个。有任何想法吗?下面是示例代码。

0 投票
2 回答
5668 浏览

vue.js - VueJs 使用来自

我有一个导航栏,并且有一个文本字段,用户可以通过标签搜索帖子。如果用户输入 1-3 个标签,写入的标签将存储在标签数组中。

我的导航栏组件中的路由器链接如下所示:(仅相关部分)

在我的 routes.js 中是我的帖子路由(我的 routes.js 的重要片段)

导航栏应该将标签数组发送到帖子组件。不幸的是我做不到。

帖子组件向获取最新帖子的 API 发送帖子请求。但我希望当标签通过时,不会获取最新的帖子,只获取带有特定标签的帖子。但首先我必须以某种方式获取标签。

我试图用“this.$props.searchTags”和其他东西来获取它们。不幸的是,结果总是“未定义”。

0 投票
2 回答
6580 浏览

android - Android TextView 中的 CSS

我有一个要在TextView中显示的html字符串。html字符串具有css内联样式和标题中的css。我想问我是否可以在TextView中显示带有css的html字符串?

我试过Html.fromHtml()了,但css不适用。

0 投票
1 回答
72 浏览

python - 如何将特定的html属性拉入变量

所以标题的措辞可能真的很糟糕,但我不知道该怎么说。所以我请求帮助使用 beautifulsoup4 来抓取数据,有人很好地帮助了我。

因此,这几乎可以完美地满足我的需要,但随后出现了问题。我需要为我的项目抓取数据的网站每天更新 _vcnonce 变量。所以我的问题真正归结为是否可以将特定的 html 字符串放入变量中。所以每次我运行代码它都会自动更新。有点像这样

或类似的东西。这是一个我需要获取信息的项目,我可以在其他网站上使用 selenium 和 beautifulsoup。但这无论如何都给我带来了问题。所以我也尝试使用 selenium,但它不起作用,我只是不确定即使使用 selenium 是否需要相同的参数。对不起这个长长的问题。不知道什么是最好的方法。

0 投票
1 回答
156 浏览

powershell - 获取有关个人工作区所有者的详细信息

在 PowerShell 中,使用Get-PowerBIWorkspace -Scope Organizition,我可以按组织方式提取工作区列表。返回的一些工作空间是个人工作空间(例如 Type = "PersonalGroup",Name = "PersonalWorkspace Ben")。

有没有办法获取关于个人工作空间所有者的名字以外的任何详细信息(例如姓氏、域用户名等)?

我正在寻找某种方法来确定哪个“Ben”(在示例的情况下)拥有工作空间,而公司中可能有几个人的名字。

0 投票
2 回答
66 浏览

scala - How fix type mismatch using tail recursion?

I need to group one list into two by index numbers, if it odd to first list, if even to second.

Here is my function

As result it have to return (List(2, 7, 0, 1), List(6, 9, 4))

Now I have problem: "Type mismatch, found: Unit, required: (List[Int], List[Int])", that highlighted at last brace

0 投票
1 回答
190 浏览

solr - Is it need to store all other fields in Solr when using In-Place Updates of single field?

I'm trying to add a full-text search feature to project. I don't want to store the full content of all documents, so I decided to use stored="false" for "content" field. Also, there is a boolean field to indicate that a document is deleted or not. When I create a new document in Solr it works great. But when I update is_deleted field - the "content" is appeared to be lost from the index and I can't search this document any more.

I have found a post that says that fields don't need to be stored when In-Place update, but it doesn't work for me.

Some details:

Schema:

Adding a test document using "/update" handler:

Update document:

Using Solr v 7.5.0.

Solr In-Place update documentation doesn't say anything about the need to store all field for this type of update.

0 投票
1 回答
71 浏览

c# - Does the Complex-struct in .NET know which sign 0 has?

In python, if I want a complex number 1+0i, then it will be represented as (1+0j); if I want the conjugate, it is represented as (1-0j). On .NET, 1+0i is represented as a tuple of floats, (1, 0), and the Complex struct doesn't seem to show any information regarding whether or not the 0 is "negative."

To account for this, I have been representing 0 values with Double.Epsilon since it's close enough as far as I'm concerned, and allows me to essentially have a negative zero.

When I use Complex.Conjugate(new Complex(1, 0)), does .NET know that the expression is now 1-0i somewhere under the hood?

0 投票
2 回答
276 浏览

java - Returning entryset in map using key value

I have two string value ID and Value coming from my code, I need to store this in a map without iterating over the map but by checking by the key value if it exists in the map. The ID can come many times with different value and in that case I have add it to the already existing entry of the ID and add the value along with the existing value

I created a Map with String and List to add the values but I am facing difficulties,

Map < String, List< String >> accessMap = new HashMap < String, List< String>>();

If the key is not present, add a new entry with ID and Value (as List).

How to find the key in the map and get the entrySet without iterating over the map and add the value alone, if the ID is already present in the map.

Example,

The id and value has to be added into a map checking if the ID is already present in the map, if not create a new entry.

The accessList might have many ID references with different value, in that case the value should be added to the entrySet of the already existing entry, the value would be a list with single value or multiple value.

0 投票
5 回答
815 浏览

javascript - 如何在 JavaScript 文件中保存 JSON 字符串?

下面的 String1 是我在此处验证的有效 JSON 字符串。但是,如果我在它周围加上引号并将它放在一个 JavaScript 文件中,我会得到一个错误 -未终止的字符串常量

0 投票
1 回答
35 浏览

awk - print the line if the first column of the current and last line are different

I need to print the lines whose first column's value is different from the last rows first column's value.

Example:

I needed following result, as this represents the rows which have different 1st columns if compared to last rows first column.

I tried following command but its not helping.

0 投票
1 回答
3164 浏览

android - Will a passed viewmodel into a recyclerview adapter cause for memory leaks?

Currently i'm experimenting with viewmodels and was wondering if passing a viewmodel to a recyclerview adapter will cause a memory leak? The only purpose of the viewmodel in the adapter is to give a new url of the image to display in the activity

I have no idea if an interface is the better way or is there a better way receive onclick events from a recyclerview?

here is my code:

Viewmodel:

}

Adapter:

}

Thank you,

Ian