Python Pandas partial match of the chain

I created a dataframe df where I have a column with the following values: category 20150115_Holiday_HK_Misc 20150115_Holiday_SG_Misc 20140116_DE_ProductFocus 20140116_UK_ProductFocus I want to create 3 new columns category | A | B | C 20150115_Holida

Using open () with the command line argument in Python

I know I'm missing something obvious. I'm using argparse to parse two input files. I get the expected output from the main function when I print the variables 'file1' and 'file2' However I attempt to use 'file1' and 'file2' in sub functions. I also a

Error 405: unauthorized method flask, ajax

Just trying to submit the form data to the MySQL DB using Ajax & Python- Flask, but the same error "method not allowed" appearing again and again.. kindly look at the codes and help me out... <div class="modal-content"> <d

pandas complicated joining operation

I would like to implement a specific join operation with the following requirements: I have a data frame in the following format, where the index is datetime and I have columns from 0 to N (9 in this example) df1: 0 1 2 3 4 5 6 7 8 9 2001-01-01 2 53

Time limit in the django model

I need a help with time-limit. I want to show user how many time he has got to rent a car. This is my views: class CarRentView(RedirectView): permanent = False query_string = True model = Car def date_of_return(request): car = Car.objects.all() car.r

For Python buckle

The following code I wrote in JavaScript, but I'm trying to convert it into something Python can understand, specifically the for loop. I tried reading up on how the for loop syntax in Python reads, but I just can't seem to wrap my head around it, si

The difference between PHP and Python in the assignment?

I have learned PHP and now I'm learning Python. I have written this code in both languages, but its behaviour differs. PHP: <?php $x = []; $y = $x; $x['key'] = 'value'; var_dump($x); var_dump($y); Python: x = {} y = x x['key'] = 'value' print(x) prin

Non persistent SSH connection

I have the following script which SSH's into a network server and executes some commands, for some reason the SSH connection opens but by the time the commands are executed it closes (I think), as a result the commands are failing with below error? C

How to create a file browser in wxpython

I am developing the GUI for my application using wxpython and have most of the features down, except in the main frame/window I want to have a box for choosing a file (in this case, the input will have to be an excel file). Something similar to the s

failed to run python scripts with jenkins

I am trying to run a Python job. I have created the following folder: C:\Users\herod\jenkins_ws\workspace\window_testing and added the script "testing.py" to it. The script is very simple: if __name__ == "__main__": print "hellow

Web crawler does not work properly

I have created a webcrawler in python 2.7 and i am using mysqldb to insert data into database. I have executed each function as a different script for different webpages, but after i put them into a single file as functions, the program shows error;

How to convert a 2x2 card into a list of lists?

Python How do I turn a grid of: x,x x,x to a list of lists?: [['x', 'x'], ['x', 'x']] It's as simple as: with open(...) as f: list_of_lists = [line.strip().split(",") for line in f] # use list_of_lists

Defining Python Functions in Google App Engine

I am new to python and am trying to define a function and then use it in Google App Engine - but I keep getting the error "Error: global name 'cache_email_received_list' is not defined" when I try to execute the function. Any help would be great

How can I convert HTML to unpolished text in Python?

I need to get plain text from an HTML document while honoring <br> elements as newlines. BeautifulSoup.text does not process <br> and newlines. HTML2Text is quite nice, but it converts to markdown. How else could I approach this?I like to use

The Django model method will not update the model field

I have a model object with a two methods: expired and pending. The expired manager works fine and updates the field. The pending manager does not work. Here is my code. Side note: I set pending to true in a view. models.py: class Job(models.Model): e

Python and class attribute declarations

I have been told that declaring dynamic attributes within a classes scope is not the 'Python Way' but I do not understand why. Could someone explain this to me or point me at some documentation as to why this is a bad thing? Honestly, I thought this

Python time zone display

I'm not sure if this is possible but here's the question: In python, is it possible to get a variable that shows the timezone relative to UTC time? For example, EST would be shown as -5, PST as -8. ThanksNot sure what you are asking exactly. Hope thi

Beautiful soup extract ()

GENERAL XML OUTLINE: <dasbhoards> <dashboard name="S1> <repository-location derived-from='http://dataviz.win.compete.com/workbooks/OTCSurvey_06_15_11_16_54/RT4?rev=' id='RT4' path='/workbooks/RetailFootwear' revision='' /> <style

Get text from the pop-up window

I'm trying to read the text from a popup window. The title is always the same. I've managed to identify the hwnd and get the title with the code below, but I can't figure out how to read the contents. import time import win32gui, win32con windows = [

Why is tuple faster than the list?

I've just read in "Dive into Python" that "tuples are faster than lists". Tuple is immutable, and list is mutable, but I don't quite understand why tuple is faster. Anyone did a performance test on this?The reported "speed of cons