I have a list like below where the first element is the id and the other is a string: I want to create a list of ids only from this list of tuples as below: I’ll use this list in __in so it needs to be a list of integer values. Answer
Tag: python
How can I make a python numpy arange of datetime
I have some input data, with timestamps in the input file in the form of hours from the date time specified in the filename. This is a bit useless, so I need to convert it to python datetime.datetime objects, and then put it in a numpy array. I could write a for loop, but I’d like to do something like:
Subtracting Dates With Python
I’m working on a simple program to tell an individual how long they have been alive. I know how to get the current date, and get their birthday. The only problem is I have no way of subtracting the two, I know a way of subtracting two dates, but unfortunately it does not include hours, minutes, or secon…
How to make a PyQT4 window jump to the front?
I want to make a PyQT4 window(QtGui.QMainWindow) jump to the front when the application received a specified message from another machine. Usually the window is minimized. I tried the raise_() and show() method but it doesn’t work. Answer This works: Both are required for me on Win7. setWindowState rest…
Python – ‘str’ object has no attribute ‘close’
I am having a great time trying to figure out why there doesn’t need to be a closing attribute for this few lines of code I wrote: I read some things and other people’s posts about this, but their scripts were a lot more complicated than what I’m currently learning, so I couldn’t figur…
Pass variables to Flask’s render_template
I want to pass multiple variables from my Flask view to my Jinja template. Right now, I can only pass one. How do I pass multiple variable when rendering a template? Answer The render_template function takes any number of keyword arguments. Query for each of the things you need in the template, then pass the …
How to implement band-pass Butterworth filter with Scipy.signal.butter
UPDATE: I found a Scipy Recipe based in this question! So, for anyone interested, go straight to: Contents » Signal processing » Butterworth Bandpass I’m having a hard time to achieve what seemed initially a simple task of implementing a Butterworth band-pass filter for 1-D numpy array (time-series). Th…
How to write bytes to file?
I have a function that returns a string. The string contains carriage returns and newlines (0x0D, 0x0A). However when I write to a file it contains only the new line feeds. Is there a way to get the output to include the carriage return and the newline? Answer If you want to write bytes then you should open t…
Python module to change system date and time
How can I change System Date, Time, Timezone in Python? Is there any module available for this? I don’t want to execute any system commands I want one common solution, which should work on both Unix and Windows. Answer I don’t have a windows machine so I didn’t test it on windows… But …
Create a single executable from a Python project [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 7 months ago. The community re…