我正在使用selenium服务器.它适用于测试在端口80上运行的应用程序.
但是,如果我测试在80以外的其他端口上运行的应用程序,例如5001,则拒绝连接.
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities;
br = webdriver.Remote(command_executor="http://localhost:4444/wd/hub", desired_capabilities=DesiredCapabilities.CHROME)
br.get("http://127.0.0.1:5001/login/")
br.get_screenshot_as_file("/tmp/test.png")
Run Code Online (Sandbox Code Playgroud)
如何在端口5001上进行测试?
编辑
我使用docker-compose运行Selenium服务器作为Docker容器:
version: '2'
services:
selenium:
image: selenium/standalone-chrome:latest
ports:
- 4444:4444
Run Code Online (Sandbox Code Playgroud) 测试数据:
curl -XPUT 'localhost:9200/customer/external/1?pretty' -d '{ "body": "this is a test" }'
curl -XPUT 'localhost:9200/customer/external/2?pretty' -d '{ "body": "and this is another test" }'
curl -XPUT 'localhost:9200/customer/external/2?pretty' -d '{ "body": "this thing is a test" }'
Run Code Online (Sandbox Code Playgroud)
我的目标是获取文档中短语的频率.
我知道如何获得文档中术语的频率:
curl -g "http://localhost:9200/customer/external/1/_termvectors?pretty" -d'
{
"fields": ["body"],
"term_statistics" : true
}'
Run Code Online (Sandbox Code Playgroud)
我知道如何计算包含给定短语的文档(使用match_phrase或span_near查询):
curl -g "http://localhost:9200/customer/_count?pretty" -d'
{
"query": {
"match_phrase": {
"body" : "this is"
}
}
}'
Run Code Online (Sandbox Code Playgroud)
如何访问短语的频率?
我曾经使用以下方法在 Redis 之间存储和读取 pandas DataFrame:
放:
redisConn.set("key", df.to_msgpack(compress='zlib'))
Run Code Online (Sandbox Code Playgroud)
得到:
pd.read_msgpack(redisConn.get("key"))
Run Code Online (Sandbox Code Playgroud)
但to_msgpack自 pandas 0.25 起已弃用,pyarrow改为使用。现在在 2.0.0 https://arrow.apache.org/blog/2020/10/22/2.0.0-release/pyarrow中弃用序列化/反序列化(如如何向/从 Redis 设置/获取 pandas.DataFrame中所示) ?)
有人知道新的推荐方式是什么吗?
编辑:我正在使用当前稳定的 pandas 版本 1.2.4
我有以下玩具数据框(真实的有 50 万行):
df = pd.DataFrame({'size': list('SSMMMLS'),
'weight': [8, 10, 11, 1, 20, 14, 12],
'adult' : [False] * 5 + [True] * 2})
adult size weight
0 False S 8
1 False S 10
2 False M 11
3 False M 1
4 False M 20
5 True L 14
6 True S 12
Run Code Online (Sandbox Code Playgroud)
而想要GROUPBY adult,选择该行的这weight是一个新的列最大,并指定size2该size列值:
adult size size2 weight
0 False S S 8
1 False S S 10
2 False …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用包含双引号半列的半列分隔符的2列csv文件(error.csv):
col1;col2
2016-04-17_22:34:25.126;"Linux; Android"
2016-04-17_22:34:25.260;"{"g":2}iPhone; iPhone"
Run Code Online (Sandbox Code Playgroud)
而我正在努力:
logs = pd.read_csv('error.csv', na_values="null", sep=';',
quotechar='"', quoting=0)
Run Code Online (Sandbox Code Playgroud)
我明白问题来自于在第3行的双引号中加了双引号"g",但我无法弄清楚如何处理它.有任何想法吗 ?
我有一个scikit-learn安装版本0.18.1 ::
$ pip uninstall -y scipy scikit-learn $ pip install scipy scikit-learn
当我导入GridSearchCV时,我得到一个奇怪的DeprecationWarning ::
(venv2) :~/$ cat warn.pyy
from sklearn.grid_search import GridSearchCV
import sklearn as sk
print(sk.__version__)
Run Code Online (Sandbox Code Playgroud)
如果我运行它我得到::
(venv2) :~/$ python warn.py
/home/n/venv2/local/lib/python2.7/site-packages/sklearn/cross_validation.py:44: DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed …Run Code Online (Sandbox Code Playgroud)