python-2.7

Python pandas to_csv zip format

人走茶凉 提交于 2021-01-02 05:51:58
问题 I am having a peculiar problem when writing zip files through to_csv. Using GZIP: df.to_csv(path_or_buf = 'sample.csv.gz', compression="gzip", index = None, sep = ",", header=True, encoding='utf-8-sig') gives a neat gzip file with name ' sample.csv.gz ' and inside it I get my csv ' sample.csv ' However, things change when using ZIP df.to_csv(path_or_buf = 'sample.csv.zip', compression="zip", index = None, sep = ",", header=True, encoding='utf-8-sig') gives a zip file with name ' sample.csv

“pip install jq” generates errors on Mac and Windows

微笑、不失礼 提交于 2021-01-02 05:08:53
问题 Duplicate of this issue, but the first answer there is wrong ( jq is supported on Windows) and the second refers to brew so I'm guessing is for Mac. Windows I am trying to install jq for python from the Windows command line, but get the following errors, possibly due to a missing temp\pip-build-rtnhmg\jq\onig-install-5.9.6 file: error: [Error 2] The system cannot find the file specified ... and ... Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\

pyplot.imsave() saves image correctly but cv2.imwrite() saved the same image as black

为君一笑 提交于 2021-01-02 04:56:19
问题 from scipy.misc import imread from matplotlib import pyplot import cv2 from cv2 import cv from SRM import SRM ## Module for Statistical Regional Segmentation im = imread("lena.png") im2 = cv2.imread("lena.png") print type(im), type(im2), im.shape, im2.shape ## Prints <type 'numpy.ndarray'> <type 'numpy.ndarray'> (120, 120, 3) (120, 120, 3) srm = SRM(im, 256) segmented = srm.run() srm2 = SRM(im2, 256) segmented2 = srm2.run() pic = segmented/256 pic2 = segmented2/256 pyplot.imshow(pic) pyplot

pyplot.imsave() saves image correctly but cv2.imwrite() saved the same image as black

落花浮王杯 提交于 2021-01-02 04:54:13
问题 from scipy.misc import imread from matplotlib import pyplot import cv2 from cv2 import cv from SRM import SRM ## Module for Statistical Regional Segmentation im = imread("lena.png") im2 = cv2.imread("lena.png") print type(im), type(im2), im.shape, im2.shape ## Prints <type 'numpy.ndarray'> <type 'numpy.ndarray'> (120, 120, 3) (120, 120, 3) srm = SRM(im, 256) segmented = srm.run() srm2 = SRM(im2, 256) segmented2 = srm2.run() pic = segmented/256 pic2 = segmented2/256 pyplot.imshow(pic) pyplot

Passing extra arguments to broyden1

耗尽温柔 提交于 2021-01-01 06:52:51
问题 Im trying to execute scipy broyden1 function with extra parameters (called "data" in the example), here is the code: data = [radar_wavelen, satpos, satvel, ellipsoid_semimajor_axis, ellipsoid_semiminor_axis, srange] target_xyz = broyden1(Pixlinexyx_2Bsolved, start_xyz, args=data) def Pixlinexyx_2Bsolved(target, *data): radar_wavelen, satpos, satvel, ellipsoid_semimajor_axis, ellipsoid_semiminor_axis, srange = data print target print radar_wavelen, satpos, satvel, ellipsoid_semimajor_axis,

Passing extra arguments to broyden1

我的未来我决定 提交于 2021-01-01 06:51:01
问题 Im trying to execute scipy broyden1 function with extra parameters (called "data" in the example), here is the code: data = [radar_wavelen, satpos, satvel, ellipsoid_semimajor_axis, ellipsoid_semiminor_axis, srange] target_xyz = broyden1(Pixlinexyx_2Bsolved, start_xyz, args=data) def Pixlinexyx_2Bsolved(target, *data): radar_wavelen, satpos, satvel, ellipsoid_semimajor_axis, ellipsoid_semiminor_axis, srange = data print target print radar_wavelen, satpos, satvel, ellipsoid_semimajor_axis,

Selenium Python test batch file does not run in Task Scheduler, browser does not open. Batch file does run ok without task scheduler

余生颓废 提交于 2021-01-01 06:28:09
问题 I have a Selenium Python test and I can run it from the batch file as follows: set TEST_HOME=%~dp0 cd %~dp0 SET PATH=%PATH%;G:\test_runners\selenium_regression_test_5_1_1\IEDriverServer\64bit cd %~dp0selenium_regression_test_5_1_1 set PYTHONPATH=%~dp0selenium_regression_test_5_1_1 c:\Python27\Scripts\nosetests.exe "%~dp0selenium_regression_test_5_1_1\Regression_TestCase\split_into_parts\RegressionProject_TestCase_Part1.py" --with-html --html-file="%~dp0selenium_regression_test_5_1_1

Selenium Python test batch file does not run in Task Scheduler, browser does not open. Batch file does run ok without task scheduler

时光总嘲笑我的痴心妄想 提交于 2021-01-01 06:25:25
问题 I have a Selenium Python test and I can run it from the batch file as follows: set TEST_HOME=%~dp0 cd %~dp0 SET PATH=%PATH%;G:\test_runners\selenium_regression_test_5_1_1\IEDriverServer\64bit cd %~dp0selenium_regression_test_5_1_1 set PYTHONPATH=%~dp0selenium_regression_test_5_1_1 c:\Python27\Scripts\nosetests.exe "%~dp0selenium_regression_test_5_1_1\Regression_TestCase\split_into_parts\RegressionProject_TestCase_Part1.py" --with-html --html-file="%~dp0selenium_regression_test_5_1_1

Automate print/save web page as pdf in chrome - python 2.7

时光毁灭记忆、已成空白 提交于 2020-12-30 06:53:06
问题 I am trying to automate Print Save Web Page as pdf in chrome. I have checked the webbrowser module, but it does not seem to be intended for this purpose. I explored wkhtmltopdf as an alternative but when downloading the file it seems to be infected by a virus. Thank you for the suggestions. 回答1: This worked for me using Chrome 62.0.3202.94, ChromeDriver 2.33.506120, Selenium 3.4.3, and Python 2.7.14 or 3.6.3, on Windows 7 x64: import json from selenium import webdriver appState = {

Can anyone please tell me what are the differences between pika and kombu messaging library in python?

杀马特。学长 韩版系。学妹 提交于 2020-12-30 04:53:32
问题 I want to use messaging library in my application to interact with rabbitmq. Can anyone please explain the differences between pika and kombu library? 回答1: Kombu and pika are two different python libraries that are fundamentally serving the same purpose: publishing and consuming messages to/from a message broker. Kombu has a higher level of abstraction than pika. Pika only supports AMQP 0.9.1 protocol while Kombu can support other transports (such as Redis). More generally, Kombu is more