text
stringlengths
226
34.5k
save data from a command to a csv file in python Question: I want to save the result of a command in a csv file. I have this code for the moment : import sys import os import time import datetime import subprocess import csv with open("compteur_data.csv","a") as csvfile: ...
cv2 import error on Jupyter notebook Question: I'm trying to import **cv2** on **Jupyter notebook** but I get this error: ImportError: No module named cv2 I am frustrated because I'm working on this simple issue for hours now. it works on Pycharm but not on Jupiter notebook. I've already installed ...
Nested for loops using multiprocessing Question: I have a quick question regarding multiprocessing in python. I am conducting a rather large grid search over three parameters and the computation is taking ~14 hours to complete. I would like to shrink this run time down by using multiprocessing. A very simplified exam...
OpenCV Python - cv2 Module not found Question: Even though I believe I have installed correctly OpenCV, I cannot overcome the following problem. When I start a new python project from IDLE (2.7) the cv2 module is imported successfully. If I close IDLE and try to run the .py file, an error message is displayed that says...
Adding non standard Python library to Beaker Lab notebook Question: I would like to use fiona (and a few other third party libraries from Github) in my Beaker Lab notebook and it's not included in the default installation. Is there a way to install new Python packages? Answer: To use python packages in a Python 2 No...
Interpreter: Python built-in functions not defined? Question: I was going through the basics of Python, and testing out some built-in functions in the interpreter. The documentation I was looking at was talking about Python 3... I am using Python 2.7.3. >>> x = '32456' >>> x '32456' >>> isalp...
How to use Python Requests to login to website, store cookie, then access another page on the website? Question: I'm trying to login into website using a Python script, store the cookie I receive, and then use that same cookie to access member-only parts of the website. I've read several posts and answers about this to...
python itertools with islice error Question: I'm still learning python and I have the code below but it is not working: from itertools import * startword = ["start",] stopword = ["stop",] text = "this is a text that starts with some test stuff and then after that it stop right here!" ...
python-docx - replacing characters Question: I am trying to build a small program in which I open a docx document and replace characters by others, to do some old school caesar-style encrypting, after checking the documentation: [ <https://python-docx.readthedocs.io> ] I am afraid I can't find the object methods and at...
Can't import Pyperclip Question: I am having trouble importing Pyperclip in IDLE. I am running windows 7 (64-bit). I have Python 3.5.2 Installed on: C:\Python\Python35. I opened command prompt and initiated the install by typing pip install pyperclip after changing directory to C:\Python\Python35\Scripts. It succ...
python isbn 13 digit validate Question: I need to write a function that validates a 13 digit ISBN. It needs to start with 978 or 979, end with a single digit, and the remaining sections need to be at least 1 digit in length. I need some help to make this work, I don't understand why it never returns true ...
Calculate F-distribution p values in python? Question: Suppose that I have an F value and the associated degrees of freedom, df1 and df2. How can I use python to programmatically calculate the p value associated with these numbers? Note: I would not accept a solution using scipy or statsmodels. Answer: The CDF for t...
Pandas Python, select columns based on rows conditions Question: I have a dataframe: import pandas as pd df = pd.DataFrame(np.random.randn(2, 4)) print(df) 0 1 2 3 0 1.489198 1.329603 1.590124 1.123505 1 0.024017 0.581033 2.500397 0.156280 ...
python xlsxwriter write cell according to row data Question: I have python dictionaries: student_age = {'bala':20,'raju':21} student_id = {'bala':289,'raju':567} and ten more similar dictionaries with key as student name and value different field. **Expected excel result:** [![enter image des...
Compress command fails on fresh installation of WireCloud Question: I cannot set up a basic wirecloud instance anymore. I tried to create a minimum Wirecloud instance like this: virtualenv venv source venv/bin/activate pip install wirecloud wirecloud-admin startproject prj cd prj/ pyt...
append page to existing pdf file using python (and matplotlib?) Question: I would like to append pages to an existing pdf file. Currently, I am using matplotlib pdfpages. however, once the file is closed, saving another figure into it overwrites the existing file rather than appending. from matplotlib.b...
Passing python list oracle where clause cx_Oracle Question: # -_\- coding: utf-8 -_ - from __future__ import unicode_literals '''Hi everybody, I'm frustrated trying to pass oracle where clause a python list , I'm using cx_Oralce here my code:''' import cx_Oracle con = cx_Oracle.conne...
crawling web data using python html error Question: i want to crawling data using python i tried tried again but it didn't work i can not found code's error i wrote code like this: import re import requests from bs4 import BeautifulSoup url='http://news.naver.com/main/ranking/read.nhn?mi...
Python: reflect positions in a 2D grid graph Question: In a 2D graph with 10x10 nodes, I realized I want the nodes to be labelled starting from the upper left corner, downwards and column-wise: 1st column -> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 2nd column -> [10, 11, 12, 13, 14, 15, 16, 17, 18, 19] a...
SQL Server Error converting data type nvarchar to date python Question: I am getting an error while calling a SQL Server stored procedure in python. > Error converting data type nvarchar to date. My code is as below. from datetime import datetime OnlyDate=datetime.now().date() # I got...
Heroku migrate app from cedar-10 to cedar-14 Question: I am just having an issue to push my changes after I followed steps to upgrade my heroku instance from cedar-10 to cedar-14. Although it works if I create new app and apply existing code, it doesn't work to on production app. > Error -----> Python ap...
Connecting to the Tor network with Python without getting "Proxy server is refusing connection" Question: I've been trying to use Tor via Python only to come across the "Proxy server is refusing connection" error. I've trying this method using the Stem library: <http://www.thedurkweb.com/automated-anonymous-interactio...
Python - Using Pandas to eliminated curly brackets and output floats Question: Having this large csv data set, that essentially has x and y values in each column. "{733.15, 179.5}", "{565.5, 642.5}", "{172.5, 375.5}", "{223.5, 554.5}",.... ...., "{213.5, 666.5}", "{851.5, 32...
nvcc fatal : Value 'sm_61' is not defined for option 'gpu-architecture' error with theano Question: I was setting up python and theano for use with gpu on; ubunutu 14.04, GeForce GTX 1080 already installed NVIDIA driver (367.27) and CUDA toolkits (7.5) successfully for the system, but on testing with theano gpu impleme...
I cant import sklearn Question: I try to import scikit-learn, but there is an error. i installed sklearn, scipy on anaconda. i am using W10 and python 3.5. >>> import sklearn Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import sklearn File "C:\Users\l...
Use both matplotlib inline and qt in jupyter notebook Question: I am using Jupyter (with IPython) to analyze research data, as well as export figures. I really like the notebook approach offered by Jupyter: when I revisit an experiment after a long time, I can easily see how the figures correspond to the data. This is ...
Defining a complex-valued, piecewise function Question: I'm trying to define a function f(x) which yields 1.0 for x = 0 and 1.0/(2j pi x) otherwise. Here is a 'test' script I'm using: import numpy as np def f(x): return np.piecewise(x,[x==0],[1.0, lambda x: 1.0/(2j*np.pi*x)]) x ...
Python dispy - keep package names for dependencies Question: Is there a way to keep the package names for python modules that are transmitted via dispy's depends feature? That would allow using packages/modules in the same way when called with and without a dispy context. Simple Example: Module mypackage.dispytestDep...
In Python, is it possible to expose modules from subpackages at package level? Question: I have the following conundrum. I'm trying to expose some modules from a subpackage of a package at the parent package level. The folder structure is the essentially like this: script.py package/ __init_...
Python3.5 -configure a single cell to expand instead of the entire row or column Question: Picture a 4x4 grid in a tkinter window. I want to expand the cell at row 2, column 2 but not everything else on row 2 or column 2. Im designing a text window with selectable options on the left side in rows 1-15. Making row 2 wit...
Python Selenium WebDriver Loop - send_keys working and then not working Question: I'm using Python 2.7, Chrome 47 (with the chrome driver), and Selenium 2.53.5. I'm practicing by creating a bot to gather info from a cvs file and then use that info to open up ebay, type in quantity, and purchase as guest. So far it work...
How to build a sparse matrix in PySpark? Question: I am new to Spark. I would like to make a sparse matrix a user-id item-id matrix specifically for a recommendation engine. I know how I would do this in python. How does one do this in PySpark? Here is how I would have done it in matrix. The table looks like this now. ...
How to let pytest rewrite assert in non-test modules Question: We defined all our custom assertions in a separate python file which is not a test module. For example: `custom_asserts.py` class CustomAsserts(object): def silly_assert(self, foo, bar): assert foo == bar , 'some error me...
Using LLDB Commands in Python Script Question: I'm writing a Python script to use in Xcode's LLDB. I have this simple script up and running: import lldb def say_hello(debugger, command, result, dict): print command def __lldb_init_module (debugger, dict): debugger.HandleComm...
PySpark (Python 2.7): How to flatten values after reduce Question: I'm reading a multiline-record file using SparkContext.newAPIHadoopFile with a customized delimiter. Anyway, I already prepared, reduced my data. But now I want to add the key to every line (entry) again and then write it to a Apache Parquet file, which...
must be string or read-only buffer, not long Question: I am making a website using flask and MySQLdb below is my python file **init.py** from flask import Flask,render_template,request,url_for,flash,session from flask_session import Session from dbconnect import connection from wtforms impor...
python read date and time from csv Question: my data looks like that: GIdx,Date,num,Time 1,11/28/2012,20,10:05:50 1,11/28/2012,20,10:05:50 2,11/28/2012,20,10:09:24 2,11/28/2012,20,10:09:24 2,11/28/2012,20,10:09:25 2,11/28/2012,20,10:09:25 2,11/28/2012,20,10:09:26 3,11/28/2...
Ctypes - Passing a Void Pointer from Python Question: I am accessing a C++ DLL using Python Ctypes on Windows 7. I have the documentation for the DLL, but I can't actually open it. I'm trying to use a C++ function that takes in a function, which in turn takes in an unsigned int and a void pointer. Here is a short code ...
How to solve error raised : No module named 'django.contrib.customuser' Question: I am new to Django, trying to create a custom user for my project. When I am running the server, it raises No module named 'django.contrib.customuser' and sometimes, Manager isn't available; auth.User has been swapped for Mysite.CustomUse...
Python - SkLearn Imputer usage Question: I have the following question: I have a pandas dataframe, in which missing values are marked by the string `na`. I want to run an Imputer on it to replace the missing values with the mean in the column. According to the sklearn documentation, the parameter `missing_values` shoul...
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7601: ordinal not in range(128) Question: I am currently running: Python 3.5.1 :: Anaconda 4.0.0 (x86_64). ERROR: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7601: ordinal not in range(128) When running the below code I get ...
Developer Inactive error when calling UnderArmour api Question: A 403 "Developer Inactive" error is received when trying to post to the [access_token endpoint](https://developer.underarmour.com/docs/v71_OAuth_2) in the UnderArmour Connected Fitness api. The **client_id** being used is active. The url used in the call i...
Python: Pass arguments to function which are stored in a file file Question: We have a databse from which we run queries. Some of these queries take a (too) long time and and since there seems to be no easy optimization (this has to do with h5py not supporting fast fancy indexing), we decided to make a cache, so that o...
Save Dataframe to csv directly to s3 Python Question: I have a pandas DataFrame that I want to upload to a new CVS file. The problem is that I don't want to save the file locally before transferring it to s3. Is there a method like to_csv for writing the dataframe to s3 directly? I am using boto3. Here is what I have...
datastax opscenter "SchedulesNotLoaded" error Question: I am using Datastax OpsCenter v5.2.4 with DSE v4.8.4-1. Since few days ago, I've been not able to retrieve the result of "Best Practice Service" both from API and opscenter UI. When I try to get it, I get errors like below. GUI: > Could not retrieve best practic...
Firebase get request: TypeError: __init__() got an unexpected keyword argument 'strict' Question: Trying to get Firebase set up and this code produces the error. I've also tried making the restful call simply using `requests` and I'm getting the exact same error. I'm using python 3.4. What's going on here? ...
First of two blocks of code of reading from a file not executing in python Question: As part of an assignment I'm writing an assembler in python that takes simplified assembly language and outputs binary machine language. Part of my code is below, where I'm reading from the assembly code in two passes. The first pass (...
must be str, not bytes | 'str' has no attribute 'decode' Question: I have this simple code to extract from a mongo database: import sys import codecs import datetime from pymongo import MongoClient sys.stdout = codecs.getwriter('utf8')(sys.stdout) mongo_db = "database" c...
Iterating list with given index list in python Question: I have a list `A = [-1, 2, 1, 2, 0, 2, 1, -3, 4, 3, 0, -1]` and `B = [0, 7, 11]`. List `B` shows the index of negative integer number index. How can I return the sum of each slice of the list: For example sum of `A[0+1:7]` and `A[7+1:11]` Answer: Using [`zip`]...
How to copy a file in a zipfile into a certain directory? Question: I need only one subfile in each of 500 zipfiles, the paths are the same, like: 120132.zip/A/B/C/target_file 212332.zip/A/B/C/target_file .... How can I copy all these target files into one directory? Keeping the entire path...
Python: Communicate between two files Question: I have a defined function in one program: def start(): QuadraticButton = Button(left_frame, text = "Quadratic Equation Solver", command = calculateQuad) QuadraticButton.pack() and then in a separate script I have the "calculate quad" function ...
Python-Rounding the value of PI according to the number specified by user Question: My Code : import math def CalPI(precision): answer = round((math.pi),precision) return answer precision=raw_input('Enter number of digits you want after decimal:') try: roundT...
The Python "Requests" module cannot detect certain HTML link tags Question: I'm sure this is an easy question for someone who has experience with webpage programming and basic Web Scraping (which I do not). My goal is to obtain information about the many tutors that Chegg hires, by scraping their "bio" paragraphs. Alt...
Recursive loops with increasing size/arguments (Hamiltonian Paths?) Python Question: I have a code that takes `n` inputs and computes the shortest distance between them without ever revisiting the same point twice. I think this the same as the Hamiltonian Path problem. My code takes `n` addresses as inputs and iterate...
Can't install datasets package via pip Question: I'm trying to run a script that requires the datasets python package. I've tried installing this unsuccessfully using pip by calling: `pip install datasets` I know this hasn't worked because when I run the script I get the message: Traceback (most recent...
Can't connect to mysql using python's mysql.connector Question: I'm using a Mac (OS 10.10.5), PyCharm, Python 3.5 and MySQL. MySQL has been working with PHP on the same machine. I'm trying to connect to it using Python and getting the error message: `enter code here`2003: Can't connect to MySQL server on 'localhost::33...
ImportError: cannot import name pubnub Question: i have problem with pubhub module in python 2.7.6. I've installed by `sudo pip install pubnub` Output: >>> import pubnub Traceback (most recent call last): File "<stdin>", line 1, in <module> File "pubnub.py", line 3, in <module> ...
PyQt Application Frozen Screen on Linux, fine on Windows Question: I have been writing a PyQt Application on Windows for awhile, and I wanted to see if it would run properly on Linux. The gui application is basically a shell for a scientific toolkit meant to be used on the qtconsole/notebook. Both Linux and Windows sys...
Motion detection + Contours (Python) Question: What's wrong with my python code. It says syntax error at line 5 "Mat frame", line 13 "std". This code was originally from C++, I converted it to Python. import numpy as np import cv2 def run_main(): cv2.Mat frame cv2.Mat back ...
How am I getting two different results from same Python print command? Question: For the first `print tag` I am getting a large list of hundreds of `<a` tags. For the second `print tag` I am getting a list with four `<a` tags, not including the ones that I want. One of the tags that tags that I want is at the end of `...
Python tkinter, restart the program Question: this is simple example of my code: from tkinter import * import random class A: def __init__(self, master): n = random.randrange(1, 10, 1) self.frame_a = Frame(master) self.frame_a.pack() ...
Letsencrypt ImportError: No module named interface on amazon linux while renewing Question: **Today when i tried to renew my certificates using this command I'm facing error** /opt/letsencrypt/letsencrypt-auto renew --config /etc/letsencrypt/config.ini --agree-tos && apachectl graceful **also tried...
editing a specific line in python 3.5.1 Question: Having trouble with overwriting a specific line in python 3.5.1 I know there are solutions out there but they use external modules or are lengthy and specific to that persons problem. is there a line of code that could do that? here is what im looking for: File.write("...
Python scraping XHR returns ValueError: Too many values to unpack Question: So for educational purposes I've got this piece of code written to scrape the 'detailed' tab of this webpage : <https://www.whoscored.com/Regions/252/Tournaments/2/Seasons/5826/Stages/12496/TeamStatistics/England- Premier-League-2015-2016> How...
python urlopen 403 inspite of URL being accessible via browsers Question: ..Hi folks ..the following URL [https://www.nseindia.com/products/dynaContent/equities/indices/historicalindices.jsp?toDate=30-06-2016&fromDate=29-06-2016&indexType=NIFTY%2050](https://www.nseindia.com/products/dynaContent/equities/indices/histor...
Create FlowMap in Python OpenCV Question: Updated question: Would anyone be able to point me in the direction of any material that could help me to plot an optical flow map in python? Ideally i want to find something that provides a similar output to the video shown here: <http://study.marearts.com/2014/04/opencv-stud...
Browser not displaying POST data PHP? Question: I have written a program to send data from python to PHP. The python code is as follows: import urllib2, urllib mydata=[('one','Check'),('two','Mate')] #The first is the var name the second is the value mydata=urllib.urlencode(mydata) path='h...
Python function replacing part of variable Question: I am writing a code for a project in particle physics (using pyroot). In my first draft, I use the following line for i in MyTree: pion.SetXYZM(K_plus_PX, K_plus_PY, K_plus_PZ,K_plus_MM) This basically assigns to the pion the val...
curl works fine, except if I call it with subprocess Question: I have a curl that looks a bit like this: curl -1 -X POST --user "xxx:yyy" -d "status=new&content=issue+details+at%3A+http%3A%2F%2Flocalhost%3A6543%2Ftest%2Fsubmit%2F16-07-03-H-20-18-&kind=bug&title=QA+Fail&responsible=xxx&priority=critical" ...
GAE datastore restore stops with The API call urlfetch.Fetch() took too long to respond and was cancelled Question: I am following this guide <https://cloud.google.com/appengine/docs/python/console/datastore-backing-up- restoring#restoring_data_to_another_app> on how to backup data in one GAE app and restore it in anot...
How can I collect this data from a div using Selenium and Python Question: I have been using Selenium and Pyton to scrape a webpage and I am having difficulty collecting data that I want out of a div that has the following structure: <div class="col span_6" style="margin-left: 12px;width: 47% !important;...
TkMessageBox - No Module Question: import TkMessageBox When I import TkMessageBox it displays the messsge _'ImportError: No module named 'TkMessageBox'_. As far as I know im using python 3.3.2 and Tk 8.5. Am I using the wrong version of python or importing it wrong ? Any answers would be extremely useful....
python sklearn KDTree with haversine distance Question: I try to create a KD tree of WGS84 coordinates and find neighbors within a certain radius from sklearn.neighbors.dist_metrics import DistanceMetric from sklearn.neighbors.kd_tree import KDTree T = KDTree([[47.8665, 8.90123]], metric=Dist...
Adding a .txt to an already zipped file Question: I have created this small python program to automate some processes I want to run. Long story short I use python to pass some information and parameters to a outside program. The outside program does its thing and zips up the results. What I am trying to do is add a "li...
How can I update a specific value on a custom configuration file? Question: Assuming I have a configuration txt file with this content: {"Mode":"Classic","Encoding":"UTF-8","Colors":3,"Blue":80,"Red":90,"Green":160,"Shortcuts":[],"protocol":"2.1"} How can i change a specific value like `"Red":90` t...
Finding the self-consistent solution to an equation Question: At the bottom of this question are a set of functions transcribed from a published neural-network model. When I call `R`, I get the following error: > RuntimeError: maximum recursion depth exceeded while calling a Python object Note that within each call t...
DRF Create and Retrieve m2m with through model Question: I want to save m2m relationship with through model # models.py from django.db import models class Student(utils.PersonalDetailsMixin, utils.ContactDetailsMixin, TimeStampedModel): guardians = models.ManyToManyField('core.Guardian'...
Plain Text export from Google Docs with PYdrive has a centered dot in Github Question: I wrote a Pydrive script which downloads all the files in a specific folder. The docs get downloaded as 'sampleTitle.md' with the mimetype of 'text/plain'. then they simply get commited and pushed to my repo. Here is my python cod...
How do I get only those lines that has highest value if they are inside a timewindow? Question: I am new to the python and scripting in general, so I would really appreciate some guidance in writing a python script. So, to the point: I have a big number of files in a directory. Some files are empty, other contain rows...
Can not infer schema for type: <type 'str'> Question: I have the following Python code that uses Spark: from pyspark.sql import Row def simulate(a, b, c): dict = Row(a=a, b=b, c=c) df = sqlContext.createDataFrame(dict) return df df = simulate("a","b",10) df.collect...
Python SimpleCookie and JSON Value Question: I've run into some problems using Python's `SimpleCookie` when using a JSON string as a value. In [1]: from http.cookies import SimpleCookie In [2]: cookie = SimpleCookie('x=1; json={"myVal":1}; y=2') In [3]: cookie.keys() Out[3]: dict_ke...
Python code structure with flask integrated Question: [Newbie] I have written a python program that does some data manipulations to imported xlsx files and save them as csv. It looks kinda like this: #!/usr/bin/env python2.7 def main(): imported_files = import_files_from_input_f...
While looping issue in Python 3.5.1 Question: Using Python 3.5.1. I am trying to build a while loop, which iterates a function until a certain number of prime numbers has been appended into a list. I have previously written a function which takes in a number, evaluates whether or not it is a prime and adds it to a lis...
how to avoid removing 0 from msb in python panda dataframe Question: i have data in column like `0123456789` after reading from a file it will get like `123456789` where column name is `msisdn` how to fix this issue am using the pandas script as follows #!/usr/bin/env python import gc import p...
How to add a custom flag to IPython's magic commands? (.ipy files) Question: Is it possible to add a custom flag to IPython's magic command? To be more specific, I want to use the %run command with a homemade flag: %run script.ipy --flag "option" and be able to use "option" inside the script. For ...
how to automatically install dependent modules used in a python app Question: I just started learning Python and a bit confused about how packages are distributed and installed. I am aware of helper scripts `easy_install` and `pip` which can be used to install the dependent modules,howerver I am not clear how to do wit...
Python: Random without repetition, but in def Question: I don't know how in def I can randomize sentences without repetition. def yellowJeden(x,m): if m <= 25: zd1 = "Juz na samym poczatku meczu "+ x.strip() + " dostal" zd2 = "Juz w " + str(m) + ". minucie meczu zawodnik d...
Python issue with linecache reading a line from an external .txt file Question: I'm hacking together my first Python project. I'm running the below Python code and having trouble with the linecache.getline. I want it to open the stoarage.txt file. Check if the number is 0. If it is, change it to 1 - play the music and ...
load Python Pickle (.pkl) file Question: I am trying to load .pkl files that are in the same directory where my .py file is located. The following is my code: import os def load_var(var_name): fid = open(os.path.join((var_name, '.pkl'))) data = pickle.load(fid) fid.close(...
Can't get Python class code to work Question: I'm new to Python. Anyway, I was trying to make a 21 questions game, but my code won't work. The error is: `Name 'plux' is not defined.` Here is the code: from random import randint class Game(object): num = randint(1, 3) def p...
DLL load failed: The specified module could not be found for pygpu/libgpuarray Question: I'm using libgpuarray (openCL) but can't seem to get the GPU working with Theano in anaconda 2. When I try to run the [test](http://deeplearning.net/software/theano/tutorial/using_gpu.html) I get: > ERROR (theano.gpuarray): pygpu ...
Bisection or Hashtable Method in Python Question: I'd like to speed up the execution time of my function in python. I read that a good way to do this is using a Bisection or Hashtable method. Do you know how I can do this with this function? from time import time import csv f = open('file.cs...
How to correctly use python libraries under Windows? Question: I am using Windows 10 and I would like to import a library from some place `P:\_Testing\Tools\Selenium\Basic` (which I added to `PYTHONPATH`). I have the following script: print(os.environ['PYTHONPATH']) from Basic import basic and ...
How To Access The Request Object in Django's GenericStackedInline Admin Question: Using **GenericStackedInline** in Django 1.9 _(Python 3.4)_ I want to access the **request** object before **saving my model** in the Django **Admin**. When using `MediaItemAdmin` I can intercept the save function before `obj.save()` is ...
How to fit parametric equations to data points in Python Question: I am looking for a way to fit [parametric equations](https://en.wikipedia.org/wiki/Parametric_equation) to a set of data points, using Python. As a simple example, given is the following set of data points: import numpy as np x_data ...
Python's multiprocessing returns more results than tasks where given Question: I'm currently trying to use multiprocessing for my simulation run, to evaluate different input values at the same time. Therefore, I googled a lot in the last weeks and got something together which is probably not very pretty but it (someho...
Unable to load patterns in AIML via Python Question: I've installed AIML via pip and wrote files _startup.py_ , _std-startup.xml_ , _basic.aiml_ and _bot_brain.brn_ in **core** folder. When I try to run _startup.py_ , I get this warning: Loading std-startup.xml... done (0.06 seconds) WARNING: No matc...
Remove decimal points and commas using regex in python Question: I have the following string: st='19.000\n20,000' i want to remove the commas and points **ONLY FOR NUMBERS**. I am using the following code re.sub(r'[^\d\.]','',st) The result is: > '19.00020000' I am newbie in ...
python SOMETIMES os.environ has no pythonpath Question: if i run the following script in Aptana Studio 3: import os from pprint import pprint pprint(os.environ['PYTHONPATH'].split(os.pathsep)) I get the following output: ['C:\\Users\\Phocas_Tommy\\plugins\\org.python.pydev_3....
Python No module named Question: I have a custom module that I am trying to read from a folder under a hierarchy: > project-source /tests /provider my_provider.py settings_mock.py __init__.py I am trying to call, from my_provide...