This question already has an answer here: Getting computer's utc offset in Python 4 answers I need to discover the timezone offset in seconds from UTC. Here's what I am trying now: timeZoneSecondsOffset = calendar.timegm(time.gmtime()) - calendar.tim
I'd like to monkeypatch some global functions in my IPython environment by a call to a library function. Basically I'd like to write from my_mod import monkeypatch monkeypatch() f=open(...) df=pd.read_csv(...) where monkeypatch wraps the behaviour of
python import os import sys if len(sys.argv) > 1: output = "" for i in range(1, len(sys.argv)): output = output + sys.argv[i] + ' ' else: output = "no argument found" print "Hello World!!!" print output php <?php $data
so basically if there's an array A [1,2,3,4,5] I wanted to reduce the following to a pandas method if there's any: for index in xrange(1,N+1): P[index] = P[index-1] + A[index-1] #O(N) to something in constant time O(1) where P = [0]*(len(A)+1) can we
This question already has an answer here: Getting the last element of a list in Python 5 answers When I work in Matlab, I use the refer to the last element of a vector with 'end'. For example: A(1, end) where A is a 2x2 matrix. Can you tell me what i
I have images on a server which I need to process. I am using python and the pysmb library. I managed to connect to the server using SMBConnection and to get a list of SharedFile items from a directory using listPath. Then, how can I read the content
I read my timesteps from a netcdf file: timesteps = ncfile.variables['time'] Now I would like to know whether some given date (say, June 23th) exists in that list. If it does, I want to omit it. The netcdf file contains arbitrary dates. I have no clu
The usual ("traditional") way of initializing certain kinds of objects prior to using them has always seemed awkward to me. As a simple example, I often see code that looks like this: my_list = [] for _ in some_iterator: # some complicated calcu
For the program I'm currently working on, I'm taking coefficients for a fit line from a file. For example, one line of the file might have the coefficients a and b in y = a + bx, or a similar function. I've been importing the coefficients and convert
As a part of the book "A byte of Python", I am writing a script to backup files. Originally, I downloaded GnuWin32 and was using zip_command = "zip -r {0} {1}".format(target, ' '.join(source) if os.system(zip_command) == 0: print('Succ
I have the following dataframe df where I am trying to drop all rows having curv_typ as PYC_RT or YCIF_RT. curv_typ maturity bonds 2015M06D19 2015M06D18 2015M06D17 \ 0 PYC_RT Y1 GBAAA -0.24 -0.25 -0.23 1 PYC_RT Y1 GBA_AAA -0.05 -0.05 -0.05 2 PYC_RT Y
I am using Beautifulsoup for easy scraping. I have figured out there are more than 5 div in webpage which I want to scrap. Their names are different but has pattern. These divs are: divnewthing divnew divnewstring etc So the pattern is divnew* kind o
from what I remember of middle school, anacondas and pythons are large snakes that overpower their prey, but anacondas are much bigger and heavier, which may be how it is overtaking my python pathway: I installed psycopg2 with an easy .exe on windows
this is really baffling me, and I cannot find the answer. import thread import time import random import sys sys.stdout.flush() def run_often(thread_name, sleep_time): while True: time.sleep(sleep_time) print "%s" % (thread_name) def run_randoml
I have two functions within my PyQt code, one for the user to pick a file path and put the file path into a text editor box. This works fine. The second function looks in that directory, finds all the files I want and sorts them for me. However, with
I am using ctypes to call a C function from Python and would like to have the function change the value of a parameter passed by reference. The function calls the function GOpen in the Galil gclib c library. In the C file below, g_param is the parame
I am proxying traffic over tor, so letter on when I need to call localhost port, it gives failure error. def create_connection(self, address, timeout=None, source_address=None): sock = socks.socksocket() sock.connect(address) return sock def getVideo
Since today, error log from apache stop writting in the path i've given, instead it goes back in the default logging file. I the apache2 vhost config, i've set the ErrorLog to a value ${APACHE_LOG_DIR}/ghost_error.log , but when there is error to log
I am trying to publish a message to rabbitmq. this works in production environment env with the same code so I suspect this is a configuration issue. rbqueue = RabbitMQClientQueue('cn-dip-v3', host = rabbitmq_config['host'], username = rabbitmq_confi
#target_filename base_source_dir = 'C:\\SourceFiles\\' base_target_dir = 'C:\\TargetFiles\\' ###read the filename_convention.txt file and put it into an array' parserlines = [line.strip().split(",") for line in open("C:\\Python34\\filename_