小编Mic*_*son的帖子

Python与Itertools?

我有一个.csv包含3列.PersonX,PersonY和PersonZ.有7000行名称和不同的组合.我的目标是看看3对和3对是最高匹配.我无法在excel中找到能够实现这一目标的公式.我确定python能够与itertools组合,但我还没那么高级.名称可以是任何顺序,只是想看看那些2或3个人在同一行中的次数.任何建议都会有很大的帮助,谢谢!

数据的小例子.

PersonX         PersonY             PersonZ
Aaron Ekblad    Keith Yandle        Vincent Trocheck
Aaron Ekblad    Denis Malgin        Mike Matheson
Aaron Ekblad    Denis Malgin        Mike Matheson
Aaron Ekblad    Jonathan Huberdeau  Keith Yandle
Aaron Ekblad    Jonathan Huberdeau  Keith Yandle
Aaron Ekblad    Jamie McGinn        Keith Yandle
Aaron Ekblad    Aleksander Barkov   Jonathan Huberdeau
Aaron Ekblad        
Adam Erne       Andrej Sustr        Vladislav Namestnikov
Adam Erne       Anthony Cirelli 
Adam Erne       
Adam Henrique   Rickard Rakell      Ryan Getzlaf
Adam Henrique   Brandon Montour     Ryan Getzlaf
Adam Henrique   Corey Perry …
Run Code Online (Sandbox Code Playgroud)

excel python-itertools python-3.x

8
推荐指数
1
解决办法
253
查看次数

结合Javascript if papercut的陈述

我的任务是将两个if语句组合Js成一个剪纸脚本.它是一个打印管理软件.我有我需要的一切我相信下面的脚本.问题是将这两个结合在一起我认为是一个陈述.我不熟悉Javascript,也不熟悉python.我希望在重新安排此脚本时提供一些帮助,如下所述.

PaperCut打印脚本API参考

目标:

如果他们打印10+页以上的作业,则仅执行成本中心弹出,否则只需将作业自动收取到公司不可计费(ADM-3900)帐户.如果作业超过50页,则将其从HP重定向到较大的复印机.在这种情况下,从test_printer3到Copier - Color.

/*
* Redirect large jobs without confirmation
* 
* Users printing jobs larger than the defined number of pages have their jobs 
* automatically redirected to another printer or virtual queue.
* This can be used to redirect large jobs from slower or high cost printers 
* to more efficient or faster high volume printers.
*/

function printJobHook(inputs, actions) {

  /*
  * This print hook will need access to all job details …
Run Code Online (Sandbox Code Playgroud)

javascript

5
推荐指数
1
解决办法
286
查看次数

使用 timedelta 减去 1 天的 Python 日期时间

我希望datetime超链接中的第一个比今天的日期早 1 天。我读了一点关于 ,timedelta但我没有看到它是如何在超链接中应用的。

http://www.nhl.com/stats/rest/skaters?isAggregate=false&reportType=basic&isGame=true&reportName=skatersummary&sort=[ {%22property%22:%22playerName%22,%22direction%22:%22ASC%22}]&factCayenneExp =gamesPlayed%3E=1&cayenneExp=gameDate%3E=%22 ' + datetime.datetime.now().strftime('%Y-%m-%d') + '%22%20and%20gameDate%3C=%22 ' + datetime.datetime.now().strftime('%Y-%m-%d') + '%22%20and%20gameTypeId=2%20and%20gameLocationCode=%22H%22

python datetime timedelta

3
推荐指数
2
解决办法
1万
查看次数

R今天()错误:找不到函数“今天”

我有一个 R 脚本,它只打印今天的日期。它在 Rstudio 中运行得很好,但是当在批处理文件中设置为任务时,它会产生以下错误

Warning message:
package 'dplyr' was built under R version 3.4.4 
Loading required package: NLP
Warning message:
package 'tm' was built under R version 3.4.4 
Error in today() : could not find function "today"
Execution halted
Run Code Online (Sandbox Code Playgroud)

这是脚本:

library(rvest)
library(dplyr)
library(tm)

yesterday <- today()
yesterday <- gsub("-", "", yesterday, fixed=TRUE)

print(yesterday)
Run Code Online (Sandbox Code Playgroud)

批处理文件:

"C:\Program Files\R\R-3.4.2\bin\R.exe" CMD BATCH --vanilla --slave "C:\Users\mike\Desktop\Make_Task\TEST_YESTERDAY.R"
timeout /t 5
Run Code Online (Sandbox Code Playgroud)

r

2
推荐指数
1
解决办法
4567
查看次数

使用 requests 和 psycopg2 在 Postgres 中创建/插入 Json

刚刚开始一个项目PostgreSQL。我想从 Excel 跳转到数据库,但我一直停留在创建和插入上。一旦我运行这个,我相信我将不得不将其切换到更新,这样我就不会继续写入当前数据。我知道我的连接正常,但出现以下错误。

我的错误是:TypeError: not all arguments converted during string formatting

#!/usr/bin/env python
import requests
import psycopg2

conn = psycopg2.connect(database='NHL', user='postgres', password='postgres', host='localhost', port='5432')

req = requests.get('http://www.nhl.com/stats/rest/skaters?isAggregate=false&reportType=basic&isGame=false&reportName=skatersummary&sort=[{%22property%22:%22playerName%22,%22direction%22:%22ASC%22},{%22property%22:%22goals%22,%22direction%22:%22DESC%22},{%22property%22:%22assists%22,%22direction%22:%22DESC%22}]&cayenneExp=gameTypeId=2%20and%20seasonId%3E=20172018%20and%20seasonId%3C=20172018') 
data = req.json()['data']

my_data = []
for item in data:
    season = item['seasonId']
    player = item['playerName']
    first_name = item['playerFirstName']
    last_Name = item['playerLastName']
    playerId = item['playerId']
    height = item['playerHeight']
    pos = item['playerPositionCode']
    handed = item['playerShootsCatches']
    city = item['playerBirthCity']
    country = item['playerBirthCountry']   
    state = item['playerBirthStateProvince']
    dob = item['playerBirthDate']
    draft_year = item['playerDraftYear']
    draft_round …
Run Code Online (Sandbox Code Playgroud)

python postgresql json

1
推荐指数
1
解决办法
2万
查看次数