text stringlengths 226 34.5k |
|---|
JSON transfer not working between processes
Question: I am creating a board game, and long story short: I want a file that will
start up and set the main variables of the game (player name, board(array),
prompt, status - playing/gameover) and export these as a .json file. The set
up file is a large GIU file so I would ... |
Cookies seem disabled (even though they're not!) with HttpURLConnection POST request to website on Android application
Question: **My problem:**
I have an Android application. I'm using HttpURLConnection to send a POST
request to a login form on an external website. The website uses cookies for
logins and I want to ch... |
Unzip all zipped files in a folder to that same folder using Python 2.7.5
Question: I would like to write a simple script to iterate through all the files in a
folder and unzip those that are zipped (.zip) to that same folder. For this
project, I have a folder with nearly 100 zipped .las files and I'm hoping for
an eas... |
Use a flask session inside a python thread
Question: How can I update a flask session inside a python thread? The below code is
throwing this error:
*** RuntimeError: working outside of request context
from flask import session
def test(ses):
ses['test'] = "test"
@app.route('/test',... |
Python time.sleep closes terminal
Question: I used this setup.py script:
from distutils.core import setup
import py2exe
setup(console=['tcphost.py'])
to compile a code that imports this:
import os
import pygame.camera
import numpy as np
import time
import cv2
... |
In python pandas DataFrames, what are the rules for automatic type conversion when setting values?
Question: If I have a dataframe which looks like
import pandas
d = pandas.DataFrame( data = {'col1':[100,101,102,103] } )
# col1
#0 100
#1 101
#2 102
#3 103
and ... |
How to send request to url that is set to 'login:admin' in google app engine?
Question: In my app.yaml, a url is defined to be:
- url: /api/.*
script: main.app
login: admin
secure: always
I tried to the following code to talk to the api
import requests
def ... |
Series imported but unused error Python
Question:
import numpy as np
from pandas import Series, DataFrame
import pandas as pd
import matplotlib.pyplot as plt
iris_df = DataFrame()
iris_data_path = 'Z:\WORK\Programming\Python\irisdata.csv'
iris_df = pd.read_csv(iris_data_path,... |
Is this a valid way to subclass a python thread to accept a variable update?
Question: I'm looking at the threading module in Python (version 3.4.3), and am having
difficulty finding a way to update a variable in the target function that is
called. I think I could create a global variable to share between the main
prog... |
Detect open circle with Python / OpenCV
Question: I have a picture with random circles shown of which one circle is always open.
The size, position and color of the circles are different each time but the
background is always white.
I want to find the coordinates of the circle which is open programmatically.
Here is a... |
How to draw a polygon of n sides, m times
Question: I'm new in Python programming and I'm having a task to develop a simple
program that draws a polygon of n sides, m times, making the leftmost edge of
the next polygon touch the rightmost edge of the previous polygon. The code
below draws a polygon depending on the num... |
python file overwriting with os module
Question: I am writing a program that will move files from one folder to another.
Sometimes I overwrite files in the process. Whenever I run the file however, I
am asked "Overwrite C:... (Yes/No/All)". I want my program to always select
"All" automatically. Thank you in advance
... |
Memory efficient sort of massive numpy array in Python
Question: I need to sort a VERY large genomic dataset using numpy. I have an array of
2.6 billion floats, dimensions = `(868940742, 3)` which takes up about 20GB of
memory on my machine once loaded and just sitting there. I have an early 2015
13' MacBook Pro with 1... |
Plotting datetime output using matplotlib
Question: So I have this code based on a simple data array that looks like this:
5020 : 2015 7 11 11 42 54 782705
5020 : 2015 7 11 11 44 55 575776
5020 : 2015 7 11 11 46 56 560755
5020 : 2015 7 11 11 48 57 104872
and the plot loo... |
Setting attribute values of XML using Python's Etree
Question: I am trying to modify XML using Python's Etree Module. I am trying to look
through a fairly complicated XML for a 'ScanItem'. The children of ScanItem
has three keys (['name', 'type', 'value']). I am looking to modify the
contents of 'value'.
Here is my co... |
WAL-E: Cannot restart postgresql after backup-fetch
Question: This is on Ubuntu 14.04 LTS
**EDIT** :
WAL-E installed using pip, with secret keys managed by `envdir`, according to
the instructions <https://gist.github.com/elithrar/8682235> and
<https://github.com/wal-e/wal-e#dependencies>.
I am trying to restore a da... |
How do I get the name of a key in PyWin32 giving its keycode?
Question: I'm reading the [PyWin32
docs](http://timgolden.me.uk/pywin32-docs/contents.html), and for some reason,
the [GetKeyNameText function](https://msdn.microsoft.com/en-
us/library/windows/desktop/ms646300\(v=vs.85\).aspx) is not there. It's not
possibl... |
DB error: django.core.exceptions.ImproperlyConfigured
Question: Getting this error when trying to create a fixture and run next command in
terminal:
django-admin.py dumpdata data.json
Full traceback:
(project)litwisha@litwisha:~/PycharmProjects/test_project$ django-admin.py dumpdata ... |
python 3 csv file - attribute error
Question: I am trying to read in the following csv file:
<https://github.com/eljefe6a/nfldata/blob/master/stadiums.csv>
I copied and pasted the contents it into excel and save it as a csv file
because it is in a unix format.
and I get the following attribute error message
Any hel... |
Python Sorting Regular Expression
Question: Hi making a file that sorts through a txt file and selects the name: and the
first 3 stats and stores them in a dict then does the same for the next name +
3 stats if dict isn't smart storing them in a list would work also I think.
## the txt file looks like this:
... |
Scrapy 1.0 - Getting return value after running from python script
Question: I am using the below code to run my crawler from a python script:
import scrapy
from scrapy.crawler import CrawlerProcess
process = CrawlerProcess()
process.crawl(MySpider)
process.start() # the script ... |
python design custom iterator
Question: I am designing a custom iterator in python:
class Iterator():
def __init__(self):
return
def fit(self, n):
self.n = n
return self
def __iter__(self):
for i in range(self.n)... |
pygame/python sprite not moving? What have i done wrong? (no errors)
Question: Alright, so here's my code, I get no errors but my sprite (player) is not
moving
import pygame,sys
import random
import time
#Colors
white = (255,255,255)
black = (0,0,0)
red = (255,0,0)
green ... |
How to open a .npz-File
Question: first I want to say, that I`m completly new in Programming and Python.
Someone send me a .npz file. Is there anyone that could explain me how to open
that file. Or which code I have to write. I already googeld quite a long time,
but I just dont understand how to open it.
Thanks in ad... |
PYTHON HELP, word not defined?
Question: so i keep getting the name 'word' is not defined on:
#for every character in secret_word
for char in word:
Context:
import time
name = input("What is your name? ")
print ("Hello, " + name, "Time to play hangman!")
... |
Errors in python script to remove NULL chars in a file
Question: Newbie question: I want to write a python script which removes all the NULL
characters in a file and count how many non-NULL characters left.
## Equivalent Linux command line:
# Linux-machine:$ tr -dc [:print:] < raw-test.txt | wc -c
#... |
Python reports invalid syntax when assigning user defined Kivy widget property
Question:
from kivy.uix.label import Label
from kivy.uix.scrollview import ScrollView
from kivy.uix.boxlayout import BoxLayout
from kivy.lang import Builder
from kivy.base import runTouchApp
from kivy.properties imp... |
Getting variable value from function of python main.py to .kv file
Question: hello guys i am not able to get variable w value from this function but if it
is out side of class so i can get the value but if it is in function i am not
able to get value
my main.py
class ExampleApp(App):
def buil... |
Regex check if backslash before every symbols using python
Question: I met some problems when I'd like to check if the input regex if correct or
not.
I'd like to check is there one backslash before every symbol, but I don't know
how to implement using Python.
For example:
* `number: 123456789`. (return `False`)
... |
wxPython: Ensure only one instance of a panel is open
Question: I'm writing a multi-window, multi-frame application. For every new
window/frame that is opened, there should be one and only one instance of that
window. I want the user to be able to quickly switch between these windows, so
`ShowModal()` does not work. I'... |
Pandas Module: Works in PyCharm but not Terminal
Question: I've written a python script (called python_script.py) in PyCharm that relies
on the pandas module. The thing is, when I run the script in PyCharm, it works
perfectly. But when I call it in terminal, I get the following error:
Traceback (most rec... |
Conditional concatenation of python pandas dataframe (sql join on self)
Question: **[Aim]**
We have an existing dataframe and wish to extract a series of records and
concat (sql join on self) given a condition in one command OR in another
DataFrame.
**[Situation]**
Python version: 3.3.3
Pandas version: 0.15.1
W... |
Can python-C++ extension get a C++ object and call its member function?
Question: I am writing a python/C++ application, that will call methods in C++ extension
from python.
Say my C++ has a class:
class A
{
private:
int _i;
public:
A(int i){_i=i;}
... |
wxPython: Dragging a file into window to get file path
Question: I want to drag a file into a window and get the file path. I've tried doing
this:
class CSVDropper(wx.FileDropTarget):
def __init__(self, data):
wx.FileDropTarget.__init__(self)
self.data = data
def OnDr... |
Why does Python refuse to execute this code in a new subprocess?
Question: I am trying to make a very simple application that allows for people to define
their own little python scripts within the application. I want to execute the
code in a new process to make it easy to kill later. Unfortunately, Python
keeps giving ... |
Python storing user input
Question: I don't have a working code at all for this, but if I wanted to take user
input and store it, and then take a different input and store that to the same
list (Like a site storing login information of it's members and associating it
when they want to log back in) how would I do this i... |
questions on multiple plots and multiple legend on python
Question: I have the following code, could any one help me fix it? I would like to have
multiple legends on python numpy / matlab graph.
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure(1)
x0 = np.array(... |
How to uri encode a large text file with python 3.4?
Question: I have a large text file that i want to be uri argument encoded. I researched
a bit and came up with this:
import urllib
f=open('text.txt','r').read()
n= open('encodeTest.txt','w')
new=urllib.quote_plus(f)
n.write(new)
... |
Python not recognizing cookies in request header
Question: At work we've been developing a python application (django specifically) that
intermittently seem to behave as if it is not recognizing some of the cookies
being sent in the request.
The issue does not always occur, but once it does it seems to persist
indefin... |
optimizing matrix operations in python, numpy
Question: This is an optimization problem. Given matrices E, H, Q, F and the logic in
method my_func_basic (see code block), populate matrix V. Any potential ways,
such as through vectorization, to speed up the computation? Thanks.
import timeit
import nu... |
Python - How to use a for loop to write data to a cell, then move to the next row
Question: I have what feels like a problem with a relatively simple solution, but to
this point it escapes my research. I'm attempting to write items from a tuple
to four consecutive rows using a for loop, but I can't seem to figure it ou... |
Iam reading learning python the hard way, i am doing the first argv exercize and getting an error
Question: In learning python the hard way exercise 13 we import `argv` for the first
time. Here is the code:
from sys import argv
script, first, second, third = argv
print 'The script is ca... |
d3 pie chart not loading
Question: All I want is to load a basic pie/donut chart, (actually a few bar plots in
addition to that , too), but looks like there is some error in my . If I
comment the same, I am able to serve the bare-bones python rendered page(but
not the pie chart, though).
<!DOCTYPE html>
... |
Python class can't be updated after being compiled
Question: I just started with python a couple of days ago, coming from a C++ background.
When I write a class, call it by a script, and afterwards update the interface
of the class, I get some behaviour I find very unintuitive.
Once successfully compiled, the class se... |
Why is Octave's function call overhead so much larger than both Matlab's and Python's?
Question: I have two pieces of code in Python and Octave that are structurally
identical. However, the Python version, implemented with numpy and scipy, is
~5x faster. I did a profile of the code, and I found that the main culprit in... |
Python recursive file renaming
Question: I am pretty new to python and I am attempting to create a python script that
is able to recursively rename every file in a directory including
subdirectories. But every time I run the script I'm getting the error
OSError: [Errno 2] No such file or directory
The directory conta... |
Three python modules, calling one another
Question: I am working on a project where I have three python modules (`a.py`, `b.py`
and `c.py`).
Module `a` is calling module `b`, module `b` is calling module `c`, and module
`c` is calling module `a`. But the behaviour is very bizzare when it runs.
Here are my three modul... |
Limiting Python Tkitner canvas scrollbar to only respond to mousewheel when full
Question: I've written the tkinter code below such that the canvas can be scrolled by
either the scrollbar or the mousewheel. The scrollbar works by default so that
it is only enabled if the content is larger than the canvas, I would like ... |
Another "slice indices must be integers or None or have an __index__ method" thread
Question: Trying to debug a Python script, and keep being this error message:
Traceback (most recent call last):
File "<input>", line 3, in <module>
TypeError: slice indices must be integers or None or have a... |
Python Tkinter Grid Checkbox
Question: I was wondering if there is an easy way to create a grid of checkboxes using
Tkinter. I am trying to make a grid of 10 rows and columns (so 100 checkboxes)
so that only two checkboxes can be selected per row.
Edit: I'm using python 2.7 with spyder
What I have so far:
... |
Having issues when install mitmproxy through pip
Question: I am having following issue when installing mitmproxy through pip. I have
tried other fixed related to egg error. Here on stack overflow. [Can't install
via pip because of egg_info
error](http://stackoverflow.com/questions/17886647/cant-install-via-pip-
because... |
Solving overdetermined system in numpy when the value of one variable is already known
Question: I'm trying to solve an overdetermined system in Python, using the
`numpy.solve` function. I know the value of one of the variables and I know
that in theory I can find a unique solution for the system if I can somehow
plug ... |
How do I take a number associated with a word and have the word printed that number of times?
Question: I have a text file with a list of words with a number and want to alter the
list so instead of having the number next to the word, the word is printed
that number of times.
So for example, with this list:
... |
python assignment of complex objects
Question: I have following code which works fine. but the minute I remove comment across
statement print `list(B)` it fails and returns as an empty list. I'm thinking
perhaps X is getting address location of `list(B)` executed as part of print
statement.
import iterto... |
Python's nested classes
Question: I'm having trouble with Python's nested classes. Here's how I have the code
set up:
class Player:
class Doll2:
def __init__(self, stats):
self.role = stats[0]
self.level = float(stats[1])
self.hp = ... |
LRANGE behaves in a very strange manner
Question: It seems as if I do not get the idea of this method (`LRANGE`). The situation
is following. I've added in `Python` some data to two lists, one called
`tables` and another one called `object_1_`. I pushed several items to list
`tables` and only one item to list `object_1... |
wxpython - How to refresh listbox from outside of class?
Question:
class ListCtrl(wx.ListCtrl):
def __init__(self, parent):
super(ListCtrl, self).__init__(parent,size=(1200,700))
def delete_items(self):
self.DeleteAllItems()
class One(wx.Panel):
b ... |
Adding new cookies with Mechanize Python
Question: I am trying to add cookies to a browser in mechanize so I am not redirected to
a click ok to agree page.
I have looked but can figure out how to do this.
I can do it using urllib2 already but wish to do it with mechanize
import urllib2
opener ... |
Python sh, set user.email to commit (Git)
Question: I'm working with [Waliki](https://github.com/mgaitan/waliki/), specifically
with waliki.git,
Waliki.git use sh to manage Git, so there, when execute a commit, user ever is
setted to `settings.WALIKI_COMMITTER_EMAIL`, looking for source (as next),
`user` at `.git/conf... |
"django.db.utils.ProgrammingError: relation "app_user" does not exist" during manage.py test
Question: My setup:
* Django 1.8.3
* Python 2.7.10
* Ubuntu 14.04
* django-two-factor-auth==1.2.0
I get the following error when I run `python manage.py test`:
Traceback (most recent call last):
... |
Quickly find first entry with a value below or equal
Question: Let's say in Python I have a list of files with their respective sizes,
represented as a dict (I don't care about the structure, you can propose
another one):
from random import randint
def gen_rand_fileslist(nbfiles=100, maxvalue=10... |
QTreeView only edits in first column?
Question: I am trying to make a simple property editor, where the property list is a
nested dict and the data is displayed and edited in a QTreeView. (Before I get
to my question -- if anyone already has a working implementation of this in
Python 3 I'd love to be pointed at it).
A... |
How to get PySerial to accept 921600 Baud rate
Question: We have a motor controller that implements a USB->Virtual COM port that has a
fixed baud rate of 921600 (the manual even states that the baud rate cannot be
changed). I found that if I use a terminal program like Terminal, I can pass
the custom baud rate of 92160... |
numpy.ndarray objects not garbage collected
Question: While trying to fine-tune some memory leaks in the Python bindings for some
C/C++ functions I cam across some strange behavior pertaining to the garbage
collection of Numpy arrays.
I have created a couple of simplified cases in order to better explain the
behavior.... |
Renaming multiple files at once with Python
Question: I am new to programming. I usually learn for a while , then take a long break
and forget most of what I learned. Nevermind that back info.
I tried to create a function which would help me rename files inside a folder
and then add an increment at the end of the new ... |
Return the value of a 2D PDF given x and y in Python?
Question: I have some data that I plotted the PDF using matplotlib's hist2D function.
The result looks like this:

The hist2d function returns a triple of arrays: H,xedges,yedges. H being the
2D hi... |
python csv TypeError: unhashable type: 'list'
Question: Hi Im trying to compare two csv files and get the difference. However i get
the above mentioned error. Could someone kindly give a helping hand. Thanks
import csv
f = open('ted.csv','r')
psv_f = csv.reader(f)
attendees1 = []
for... |
Reccommended way to redirect file-like streams in Python?
Question: I am writing a backup script for a sqlite database that changes very
intermittently. Here's how it is now:
from bz2 import BZ2File
from datetime import datetime
from os.path import dirname, abspath, join
from hashlib import s... |
Read. Check. Write. A Broken Python script
Question: I am developing a word game, and for this game, I needed a list of words.
Sadly, this list was _so_ long that I just had to refine it (this list of
words can be found on any Mac at **/usr/share/dict/**).
To refine it, I decided to use my own Python scripts. I alread... |
How to simplify for loop in prime number generator in python
Question:
import math
def is_prime(num):
if num < 2:
return False
for i in range(2, int(math.sqrt(num))+ 1):
if num % i == 0:
return False
return True
Primes seems to be a pop... |
twisted critical unhandled error on scrapy tutorial
Question: I'm new in programming and I'm trying to learn scrapy, using scrapy tutorial:
<http://doc.scrapy.org/en/latest/intro/tutorial.html>
So I ran "scrapy crawl dmoz" command and got this error:
2015-07-14 16:11:02 [scrapy] INFO: Scrapy 1.0.1 start... |
Using TinyMCE with Django, I see ImportError: Cannot import name simplejson
Question: I'm using Django and TinyMCE on Windows. When I run the following in the
command prompt:
>
> python manage.py runserver
>
I get
>
> ImportError: Cannot import name simplejson
>
Below is the entire console output includ... |
UnicodeDecodeError - encoding in Python
Question: I'm trying to connect to a database on a web hotel. However, I get this error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xf8 in position 24: ordinal not in range(128)
The error is on the same line as the hostname and database name. I'd ra... |
POST request with form data using Python's request
Question: I am trying to query this API from within Python. It seems to respond with 400
code. Can some one tell me how should this API be queried?
This API is documented at <http://text-processing.com/docs/phrases.html>
import requests
r = requests... |
Requests works and URLFetch doesn't
Question: I'm trying to make a request to the particle servers in python in a google app
engine app.
In my terminal, I can complete the request simply and successfully with
requests as:
res = requests.get('https://api.particle.io/v1/devices', params={"access_token": {... |
Input into a polynomial regression formula with Python
Question: I inherited a project in the middle of pandemonium and to makes matters worse
I am just learning python.
I managed to implement a polynomial function into my code and the results are
the same as the ones posted in the examples of this web page. [z =
nump... |
Using ProxyMesh (https://proxymesh.com ) IP in selenium chrome driver for web scrapping
Question: I have performed web-scrapping using python-scrapy framework with a Proxy Mesh
IP. If the proxy requires authentication I use the following code :
import base64
# Start your middleware class
cla... |
How to slice strings backwards python
Question: I am learning python and I made a basic program where the user takes the link
of a photo and inputs it, then the program downloads that photo. In order to
make sure that the user doesn't enter a link that is a webpage instead of a
photo, I had the program check what the f... |
python: sigsegv when using ctypes on cygwin
Question: I am trying to compile and use a c library in python using ctypes module. The
library is strangely working fine on Linux machine but throwing SIGSEGV on
Cygwin64.
import ctypes
import numpy as np
import pdb
xbry = np.array([0.9, 0.1, ... |
Memory leak in opencv 2.x
Question: I'm running a python script and it is giving insufficient memory error. I
tried executing this script with both 2.4.9 and 2.4.11 and got the error. Is
there any issue with these 2 versions of opencv?
* * *
import numpy as np
import cv2
MIN_MATCH_COUNT = 10... |
elasticsearch python regex query
Question: I want to execute queries like "my * is" which should yield results like "my
name is", "my car is" etc.
from elasticsearch import Elasticsearch
from elasticsearch_dsl import Search
client = Elasticsearch([
{'host': 'localhost', 'port':9200}
... |
Writing a networkx graph with position, color, ect to gexf
Question: I have constructed a graph using networkx and used the spring layout function
to generate a nice plot, unfortunately this is not transferred to the gexf
file
I think that the point of the networkx tool is to be able to write readable
graph files so I... |
Perform function on multiple columns in python
Question: I have a data array of 30 trials(columns) each of 256 data points (rows) and
would like to run a wavelet transform (which requires a 1D array) on each
column with the eventual aim of obtaining the mean coefficients of the 30
trials. Can someone point me in the ri... |
Python-Jira installation without Admin rights
Question: I am writing a python tool that should get information from Jira. I wanted to
use Python-Jira but cannot install it properly. I am using (have to use)
python 2.7 which doesn't come with pip and I cannot install pip because I do
not have local admin rights (and won... |
Slow ANTLR4 generated Parser in Python, but fast in Java
Question: I am trying to convert ant [ANTLR3
grammar](https://github.com/fabsx00/codesensor/blob/master/CPPGrammar.g) to an
[ANTLR4 grammar](https://gist.github.com/zevektor/630f1e9356fe200574d9), in
order to use it with the antlr4-python2-runtime. This grammar i... |
How to diagnose extra SQLAlchemy connections in Pyramid
Question: When my app runs, I'm very frequently getting issues around the connection
pooling (one is "QueuePool limit of size 5 overflow 10 reached", another is
"FATAL: remaining connection slots are reserved for non-replication superuser
connections").
I have a ... |
Checking that array doesn't contain negative numbers, and running function again if it does
Question: My task today is to create a way for checking if a function's output contains
negative numbers, and if it does, then I must run the function until it
contains no negative numbers.
I'll post the full code later in the ... |
Nested list doesn't work properly
Question:
import re
def get_number(element):
re_number = re.match("(\d+\.?\d*)", element)
if re_number:
return float(re_number.group(1))
else:
return 1.0
def getvalues(equation):
elements = re.findall("([a-z... |
discontinous axis in subplot - python matplotlib
Question: I would like to have plot with an y axis that is devided into two parts. The
lower part should have a normal scale while the upper one should scale with a
factor of 10.
I already found some examples on how to make plots with broken x or y axes,
for example: <h... |
Spark Word2Vec example using text8 file
Question: I'm trying to run this example from apache.spark.org (code is below & entire
tutorial is here: <https://spark.apache.org/docs/latest/mllib-feature-
extraction.html>) using the text8 file that they reference on their site
(<http://mattmahoney.net/dc/text8.zip>):
... |
Get access token from Paypal in Python - Using urllib2 or requests library
Question: ### cURL
curl -v https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "client_id:client_secret" \
-d "grant_type=client_credentials"
... |
Excluding data from a pandas dataframe based on percentiles
Question: I am having difficulties trying to use Python to remove some data outliers
prior to producing a scatterplot. I have a n by 43 dataframe imported using
pandas. I have figured out how to determine the thresholds for the outliers
and applied this to the... |
Difference between .py and .app script on Google App Engine
Question: According to [Google App Engine
doc](https://cloud.google.com/appengine/docs/python/config/appconfig#Python_app_yaml_Script_handlers),
the script handler can call three types of Python scripts to handle the
request match by the URL pattern.
> A scri... |
How to modify XLSX column formatting with Python
Question: I have hundreds of XLSX files which all have columns containing long numeric
account numbers. I need to automatically convert all of these files to CSV.
This is trivial with tools like `ssconvert`. However, due to a ~~bug~~
[feature](http://superuser.com/questi... |
How to sum elements of a list corresponding to elements of another list in python
Question: I have two lists:
a=[25,23,18,28]
and
b=[1,2,2,3]
I want to sum the corresponding values in `a` to similar values in `b`, so it
would look like this:
return_a=(25,41,28)
... |
Datetime and Timestamp equality in Python and Pandas
Question: I've been playing around with datetimes and timestamps, and I've come across
something that I can't understand.
import pandas as pd
import datetime
year_month = pd.DataFrame({'year':[2001,2002,2003], 'month':[1,2,3]})
year_mo... |
PyQt error “QProcess: Destroyed while process is still running”
Question: When I try to run the following PyQt code for running processes and tmux, I
encounter the error `QProcess: Destroyed while process is still running.` How
can I fix this?
#!/usr/bin/env python
#-*- coding:utf-8 -*-
impo... |
Decoding error in paths using nltk.corpus.gutenberg.fileids()
Question: When I run `nltk.corpus.gutenberg.fileids()` with Python 2.7 (Anaconda,
Windows) I get the following error:
File "C:\Anaconda\lib\ntpath.py", line 85, in join
result_path = result_path + '\\'
UnicodeDecodeError: 'asc... |
pyclbr cannot import classes from another directory?
Question: This works fine if A.py and B.py are in the same directory
# module.py
class A(object):
pass
class B(A):
pass
# module2.py
import module
class C(module.B):
pass
that works fine:
... |
Correct way to create /etc/machine-id from python
Question: I want to create systemd's `/etc/machine-id` from a python script instead of
using `systemd-machine-id-setup`. I am preparing a rootfs and I don't want to
depend on systemd being installed on the host.
My current code looks like this:
from uuid... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.