我无法找到一种好方法来查找列中的所有负条目并将它们向上移动到列中,将它们与现有条目相加(即从当前条目中减去负条目),直到所有值都是正值。
重要的是,最终数据帧没有负值 & 所有以前的负条目 = 0。此外,该表是重复的,这意味着我需要根据 ID 和条目汇总结果(只对相同 ID 的条目进行求和)。
基于此处已提供的表格:
展示:
ID | 日期 | 参赛作品 |
---|---|---|
1 | 2013年 | 100 |
1 | 2014年 | 0 |
1 | 2015年 | 60 |
1 | 2016年 | -30 |
1 | 2017年 | 0 |
1 | 2018年 | 50 |
1 | 2019年 | 0 |
1 | 2020年 | -20 |
2 | 2013年 | 100 |
2 | 2014年 | 0 |
2 | 2015年 | 60 |
2 | 2016年 | -30 |
2 | 2017年 | 0 |
2 | 2018年 | 50 |
2 | 2019年 | 0 |
2 | 2020年 | -20 |
期望:
ID | 日期 | 参赛作品 |
---|---|---|
1 | 2013年 | 100 |
1 | 2014年 | 0 |
1 | 2015年 | 30 |
1 | 2016年 | 0 |
1 … |
这是我的代码
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome
driver.get("http://www.python.org")
Run Code Online (Sandbox Code Playgroud)
我收到了错误
Traceback (most recent call last):
File "E:/codes/python/script.py", line 5, in <module>
driver.get("http://www.python.org")
TypeError: get() missing 1 required positional argument: 'url'
Run Code Online (Sandbox Code Playgroud)
我提到了文档,但那里没有太多信息
所以我目前正在开发一个 python 抓取工具,用 python 中的 selenium 收集网站信息。我遇到的问题是,如果我前往一个不活跃的页面,我会收到错误消息:unknown error: net::ERR_NAME_NOT_RESOLVED
我有一段时间没有使用 python,所以我的知识不是最好的。
这是我的代码
driver = webdriver.Chrome(ChromeDriverManager().install())
try:
driver.get('%s' %link)
except ERR_NAME_NOT_RESOLVED:
print ("page down")
Run Code Online (Sandbox Code Playgroud)
示例网站:http : //www.whitefoxkeeping.co.uk
错误
Traceback (most recent call last):
File "C:\Users\STE\AppData\Local\Programs\Python\Python39\selenium email\selenium test.py", line 106, in <module>
driver.get('%s' %url)
File "C:\Users\STE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get
self.execute(Command.GET, {'url': url})
File "C:\Users\STE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\STE\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: net::ERR_NAME_NOT_RESOLVED
(Session info: chrome=87.0.4280.88)
Run Code Online (Sandbox Code Playgroud)
我已经搜索了以前的问题,似乎无法找到解决方案。
任何帮助将不胜感激:)