text stringlengths 226 34.5k |
|---|
Mininet - Need custom tree topology script
Question: Can someone show me a python script that creates a simple custom topology in
Mininet, that uses a tree topology with a depth and fanout of 2? It would be
greatly appreciated.
Answer: Example:
from mininet.topo import Topo
class CustomTopo(To... |
How to develop/include a Django custom reusable app in a new project? Are there some guidelines?
Question: following [tutorial on Django reusable
apps](https://docs.djangoproject.com/en/1.8/intro/reusable-apps/) things work
fine. But I have some questions on the process of developing and packaging a
Django app.
1 - In... |
Portfolio rebalancing with bandwidth method in python
Question: We need to calculate a continuously rebalanced portfolio of 2 stocks. Lets
call them A and B. They shall both have an equal part of the portfolio. So if
I have 100$ in my portfolio 50$ get invested in A and 50$ in B. As both stocks
perform very differently... |
python scrapy login redirecting problems
Question: I'm trying to use scrapy to crawl a website, but I'm not able to login to my
account through scrapy. Here is the spider code:
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from images.items import ImagesItem
... |
Reusing connections in Django with Python Requests
Question: What's the correct way of reusing [Python Requests](http://docs.python-
requests.org/en/latest/api/) connections in Django across multiple HTTP
requests. That's what I'm doing currently:
import requests
def do_request(data):
re... |
Extract names around each word regex
Question: There is a string
Mary loves Mike,Jack loves Lily,Ethan loves Lydia
I want to extract the names around each `loves` with python.But the code below
can't work.
names = re.search(r'(\S+) loves (\S+)',str, )
while names:
print... |
How can the variable be used by other functions in TkfileDialog?
Question: I intended to write a GUI to import URLs data then process these data, so I
had 2 buttons. Below is my code.
from Tkinter import *
root=Tk()
root.title('Videos Episodes')
root.geometry('500x300')
... |
How can I duplicate python 2 chr exactly in python 3
Question: Hi I am trying to migrate some code to python 3 but am having the following
problem.
Python 2
>>> a = chr(217)
>>> print a, type(a)
� <type 'str'>
Python 3
>>> a = chr(217)
>>> print(a, type(a))
Ù <class ... |
Python thread memory layout (in combination with boost::python)
Question: I have a boost::python application written in C++. This code is compiled into
a binary that also includes the Python interpreter. The binary is then called
with a Python script that imports the C++ module:
./c++executable script.py... |
Retrieve task result by id in Celery
Question: I am trying to retreive the result of a task which has completed. **This
works**
from proj.tasks import add
res = add.delay(3,4)
res.get()
7
res.status
'SUCCESS'
res.id
'0d4b36e3-a503-45e4-9125-cfec0a7dca30'
But I want to ru... |
Difficulty installing python modules after installing anaconda
Question: I just started working with anaconda. Earlier I was working with Python 2.7 on
my system. I was writing a script for devices connected to my laptop via usb.
For this, I needed the usb module/package. I initially tried doing in Python
27. I install... |
Trying to download data from URL with CSV File
Question: I'm slightly new to Python and have a question as to why the following code
doesn't produce any output in the `csv` file. The code is as follows:
import csv
import urllib2
url = 'http://www.rba.gov.au/statistics/tables/csv/f17-yields.c... |
Need Clarification on Using OOP and DRY Method in Python
Question: I'm trying to keep my code clean by applying OOP and DRY method; however, I
found myself stuck with the following questions.
1) Since **checkremote** and **backup** method are dependent on the
**sshlogin** method, is there another way to write it so th... |
how to write the output of iostream to buffer, python3
Question: I have a program that reads data from cli sys.argv[] and then writes it to a
file. I would like to also display the output to the buffer.
The manual says to use getvalue(), all I get are errors. [Python3
manual](https://docs.python.org/3/library/io.html)... |
How do I get flask-cor to return Access-Control-Allow-Origin on Google App Engine?
Question: My python app does not throw any errors on Google App Engine, but the Allow-
Control-Access-Origin header is never sent. How can I ensure that I am sending
it with flask-cors?
import MySQLdb
import os
imp... |
python pandas read_excel returns UnicodeDecodeError on describe()
Question: I love pandas, but I am having real problems with Unicode errors. read_excel()
returns the dreaded Unicode error:
import pandas as pd
df=pd.read_excel('tmp.xlsx',encoding='utf-8')
df.describe()
------------------... |
How can I import my own modules on webserver?
Question: I am developing a website and want to put some files on the server. The
problem is that I can only import python modules ( e.g. "import os"), but
somewhy, can not import my own modules:
test1.py:
import test2
test2.py:
print ("... |
How do I make a decaying oscilating function in python?
Question: I have a code in python to represent the energy decay in a damped oscilator,
it reads like this:
def E(wt, Q):
return (np.e**(-x/Q))*(1-(1/2*Q)*np.sin(2*x))
x = np.linspace(0,20,1000)
y0 = E(x,2)
y1 = E(x,4)
y2 = E(... |
how use ctypes with msvc*.dll from within matlab on windows
Question: i'm using winpython (2.7) on windows 7/64, matlab 2015a, with matlab's new
[python bridge](http://www.mathworks.com/help/matlab/call-python-
libraries.html).
>> py.ctypes.util.find_library('c')
ans =
Python str wit... |
Processes don't terminate when I call Python script using crontab
Question: I have a script called yarn_monitor.py. When I run it, the program executes
correctly and when I look at the running processes using `ps -u myname`,
everything is clear.
But when I run yarn_monitor.py using cron:
* * * * * /home... |
How to compare list of arrays in python?
Question: I want to compare two variables `input_items` and `temp` for equality. To give
you an idea of their datatype -
print input_items
prints -
`[array([ 50., 1., 0., ..., 0., 0., 0.], dtype=float32), array([ 50., -2., 0.,
..., 0., 0., 0.], dtype=float3... |
Substitute all xml text with beautifulsoup library
Question: I need to replace all the text in a xml using Beautifulsoup library in Python.
For example, i have this peace of xml:
<Paragraph>
Procedure general informations
<IntLink Target="il_0_mob_411" Type="MediaObject"/>
<Strong>DIFFICULTY:... |
Executing stored procedures in sqlalchemy
Question: I am using a raw_connection in sqlalchemy to execute some SQL that runs a
stored procedure.
the stored proc selects a parameter ID at the end. How can I catch this ID?
the python code is:
import sqlalchemy as sa
SQLCommand = """
DECLA... |
Python - How to add a space string (' ') to the end of every line in a text/conf file
Question: I have a config file that i would like to add a space (' ') to the end of
every line in the file
**File example:**
#xxx configuration
IPaddr = 1.1.1.1<add a space here>
host = a.b.c.d<add a space here... |
UnicodeDecodeError when reading a text file
Question: I am a beginner to Python (I am using 3.4). This is the relevant part of my
code.
fileObject = open("countable nouns raw.txt", "rt")
bigString = fileObject.read()
fileObject.close()
Whenever I try to read this file I get:
... |
python3: convert string to type
Question: I have a set of classes `A`, `B`, `C` in a "front end" package `p1`. They all
inherit from `p1.X`.
I have another set of classes `A`, `B`, `C` in a "back end" package `p2`. They
all inherit from `p2.Y`.
In `p1.X`, I set one backend, so that `p1.A` uses `p2.A` as backend, `p1.... |
Running Psychopy window from a thread segfaults
Question: I'm trying to run my Psychopy window from a separate thread and control what's
shown on it from another one, but all I get is Fatal Python error.
Here's a small example script that produces the same results as my larger one
from threading import ... |
how install jsonrpc on macos for python27
Question: I want to check the operation of the code:
from txjsonrpc.web import jsonrpc
from twisted.web import server
from twisted.internet import reactor
class Math(jsonrpc.JSONRPC):
"""
An example object to be published.... |
Why do the Frechet distributions differ in scipy.stats vs R
Question: I've fitted a frechet distribution in R and would like to use this in a python
script. However inputting the same distribution parameters in
scipy.stats.frechet_r gives me a very different curve. Is this a mistake in my
implementation or a fault in s... |
Python 3.4 : match from csv and return new csv with matched values
Question: # QUESTION
How can I scan the reader csv for any items in the reader2 csv and return a
new csv with the matched information.
# Reader2 csv format
66740,1800,1001463,1467373,896159
# reader csv format
10013... |
Opening a Word document that has a password using docx library
Question: I'm trying to open a word document that has a password.
I'm using docx package - a bit old
from docx import opendocx, getdocumenttext
and further on
document = opendocx(filename)
I was wondering if there... |
Using Z3 with python in Visual studio 2013
Question: I installed the Python 2.7.10 64 bit. I downloaded the latest Z3 sources from
<https://github.com/Z3Prover/z3>. I copied the folder z3-master in the
Python27 folder. Then, I opened the Visual Studio 2013 command prompt and
build the z3 using instructions provided on ... |
Python multiprocessing: name of the main process
Question: I'm using the multiprocessing module to run a piece of code on different
processes. At some point in the code, I need to know whether the code is being
executed by the main process or one of the created child processes.
In all cases I've tried, the name of the... |
Python 3.x AttributeError: 'NoneType' object has no attribute 'groupdict'
Question: Being a beginner in python I might be missing out on some kind of basics. But
I was going through one of the codes from a project and happened to face this
:
> AttributeError: 'NoneType' object has no attribute 'groupdict'
Following i... |
Getting time difference in python 2.7
Question: I am importing some data from a REST API into a list. One of the columns
contains just date/time information.
Column A format/example : `2015-06-11 07:59:10.000 GMT`
I need to be able to check the time difference between two rows , i tried
using
datetime.... |
Django + DjangoCMS signal handlers not being called
Question: So, in Django 1.7.7 a new way to handle signals was introduced. I'm using
`1.7.7` with `django_cms`, running on Python 2.
I'm trying to implement this new way, and even though the documentation is
scarce but straightforward enough, it **just won't work**. I... |
Identify the column that the highest row value belongs to, python or R
Question: So i'm going to a table that will be 20 columns by `x` rows and I need to find
for each row which column the highest value belongs to. ex:
The Table would be something like this (but larger)
A B C D ... |
How to unzip an iterator?
Question: Given a list of pairs `xys`, the Python idiom to unzip it into two lists is:
xs, ys = zip(*xys)
If `xys` is an iterator, how can I unzip it into two iterators, without
storing everything in memory?
Answer: If you want to consume one iterator independently from ... |
Using Py2app with a GUI from QT Creator
Question: I created a GUI in QT Creatro and stored this as a *.ui file. Using PyQT I
made a GUI that works fine when it is launched as
$ python pyapp.py
In order to build this app into something that can be executed by double
clicking on it, I used Py2app. Ho... |
How to increase the performance for estimating `Pi`in Python
Question: I have written the following code in Python, in order to estimate the value of
`Pi`. It is called [Monte
Carlo](https://en.wikipedia.org/wiki/Monte_Carlo_method) method. Obviously by
increasing the number of samples the code becomes slower and I ass... |
How to select columns from dataframe by regex
Question: I have a dataframe in python pandas. The structure of the dataframe is as the
following:
a b c d1 d2 d3
10 14 12 44 45 78
I would like to select the columns which begin with d. Is there a simple way
to achieve... |
How to crawl latest articles in a specific site using specific set keyword?
Question: I am trying a python code for crawling article links on specific sites based
on key word like name of the article.but i didn't get the links appropriate
links.
import sys
import requests
from bs4 import Beautifu... |
How to handle a huge stream of JSON dictionaries?
Question: I have a file that contains a stream of JSON dictionaries like this:
{"menu": "a"}{"c": []}{"d": [3, 2]}{"e": "}"}
It also includes nested dictionaries and it looks like I cannot rely on a
newline being a separator. I need a parser that co... |
How to display every key and value in a dictionary apart from one in python
Question:
dict1 = {"Bear":3,"Wine":3,"Spirits":7,"No":0}
Here I have a dictionary and I want to display every key and value from Bear,
Wine and spirits so it would look something like this:
Bear 3
Wine 3
Spirit... |
Caffe net.predict() outputs random results (GoogleNet)
Question: I used pretrained GoogleNet from
<https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet> and
finetuned it with my own data (~ 100k images, 101 classes). After one day
training I achieved 62% in top-1 and 85% in top-5 classification and try to
us... |
Python doesn't print with import scapy
Question: When I enter this code:
print "hhhh"
from scapy.all import sniff
print "bbbb"
this is the output:
C:\Python27\python.exe C:/Users/Tamir/PycharmProjects/SIP/main.py
hhhh
WARNING: No route found for IPv6 destination :: (n... |
Pass argument from command button on Access form to python script
Question: Using Access 2010 and python 2.7.8
Have a command button on Access 2010 form. I am trying to pull the value from
the Field1 text box and pass it to a python script. I am struggling with
passing the variable. Commented out stuff is other things... |
Trouble parsing html files (to csv) using ElementTree xpath in python
Question: I am trying to parse a few thousand html files and dump the variables into a
csv file (excel spreadsheet). I've come up against several roadblocks--the
first one which was (thankfully) solve here, a few days ago. The (hopefully)
final roadb... |
Finding the 5 smallest numbers from a list in Python
Question: I have a list of names,x, and a list of scores,y, that correspond to the
names.
x = {a,b,c,d,e,f,g,h,i,j,k}
y= {8,8,15,13,12,17,18,12,14,14}
So, a has score 8, b has scores 8, c has score 15, ..., k has score 14
I want to find th... |
With @csrf_exempt still have Set-Cookie: csrftoken
Question: With Django 1.8, I do not want to have a cookie set on the homepage of my site
when the users are not logged in. So I decorate my view with @csrf_exempt like
from django.views.decorators.csrf import csrf_exempt
@csrf_exempt
def ma... |
Can not connect to an abstract unix socket in python
Question: I have a server written in c++ which creates and binds to an abstract unix
socket with a namespace address of `"\0hidden"`. I also have a client which is
written in c++ also and this client can **successfully** connect to my server.
BTW, I do not have the s... |
how to sort data according to date in python
Question: I have a input file in the following format:
457526373620277249 17644162 Sat Apr 19 14:29:22 +0000 2014 0 nc nc U are expressing a wish not a fact ;) @Manicdj99 @ANTIVICTORIA @Nupe117 @cspanwj
457522541926842368 402127017 Sat Apr 19 1... |
How to access fields with StrategyPattern in Python?
Question: I'm trying to use the Strategy Pattern to include different behaviours for
different sizes of a simulation.
I came across [this
implementation](http://codereview.stackexchange.com/questions/20718/strategy-
design-pattern-with-various-duck-type-classes) fro... |
Python internal error Handling
Question: I'm having issues with my program just closing at random stages and am not
sure why.
At first, I thought it was because it was getting an error but I added an
error handle. still for some reason it just closes after say a few days of
running and no error is displayed. code belo... |
Traceback from a Python Script: invalid literal
Question: In short, what the Python script is supposed to do is to load and calculate
ASCII type files.
With some previously pre-processed files, it works without errors, while with
mine it throws an error. In any case, it looks as though my file is different
from what i... |
Calculate how a value differs from the average of values using the Gaussian Kernel Density (Python)
Question: I use this code to calculate a Gaussian Kernel Density on this values
from random import randint
x_grid=[]
for i in range(1000):
x_grid.append(randint(0,4))
print (x_grid)
... |
python Matplotlib gtk - animate plot with FuncAnimation
Question: I am trying to update a plot within my GTK window with FunkAnimation. I want
to click a button to start updating the plot which gets its data from a txt
file. The txt-file gets updated constantly. The intent is to plot a
temperature profile. Here is the ... |
Python: Using re module to find string, then print values under string
Question: I am attempting to use the re module to search a string of a fairly large
file. The file I am searching has the following format:
220
BOX 1, STEP 1
C 15.1760586379 13.7666285127 ... |
Ignoring samples in Gibbs sampling
Question:
import random,math
def gibbs(N=50000,thin=1000):
x=0
y=0
print "Iter x y"
for i in range(N):
for j in range(thin):
x=random.gammavariate(3,1.0/(y*y+4))
y=random.gauss(1.0/(x+1),1.0/ma... |
How to print iterations per second?
Question: I have a small Python script which sends POST requests to a server and gets
their response.
It iterates 10000 times, and I managed to print the current progress in
command prompt using:
code=current_requestnumber
print('{0}/{1}'.format(str(code),"10000")... |
Python: How to use an item from a python list which appears a specific number of times?
Question: Suppose I have a python list num = [1,2,5,3,4,4] and I know that there is an
item which appears 2 times in num. Now I want to use only that item. Is there
a predefined function to choose that item?
*There is no upper limi... |
Run 3 variables at once in a python for loop.
Question: For loop with multiple variables in python 2.7.
Hello,
I am not certain how to go about this, I have a function that goes to a site
and downloads a .csv file. It saves the .csv file in a particular format:
name_uniqueID_dataType.csv. here is the code
... |
Convert float to log space in python
Question: I am implementing the Viterbi algorithm (a dynamic algorithm) in Python, and I
notice that for large input files, the probabilities keep getting multiplied
and shrinking beyond the floating point precision. I need to store the numbers
in log space.
Can anyone give a simpl... |
UnicodeEncodeError Python 2.7
Question: I am using Tweepy for authentication and I am trying to print text, but I am
unable to print the text. I am getting some UnicodeEncodeError. I tried some
method but I was unable to solve it.
# -*- coding: utf-8 -*-
import tweepy
consumer_key = ""
... |
Problems while importing pyaudio
Question: I recently bought a new laptop , and i moved my files from my old laptop. I
was working on a project in pycharm which used the module pyaudio , i tried to
run it and i got an error saying there is no module called pyaudio.
I ran "apt-get install python-pyaudio" , it was succe... |
Import on class instanciation
Question: I'm creating a module with several classes in it. My problem is that some of
these classes need to import very specific modules that needs to be manually
compiled or need specific hardware to work.
There is no interest in importing every specific module up front, and as some
mod... |
Django TemplateDoesNotExist Error on Windows machine
Question: I have been following the tutorial for Django **[Tango with
Django](http://www.tangowithdjango.com/book17/chapters/setup.html#django-
basics)**
I was trying to add a template as instructed on the
[link](http://www.tangowithdjango.com/book17/chapters/templa... |
Python import statement in a loop: does import run every loop iteration?
Question: For a code I am writing, I am running `scipy.curve_fit()` tens of thousands of
times. I noticed in the [relevant `curve_fit()` source
code](https://github.com/scipy/scipy/blob/v0.14.0/scipy/optimize/minpack.py),
specifically on [lines
43... |
cx_Oracle imports wrong module
Question: I am trying to connect to an Oracle DB v.9. I downloaded latest Instant Client
(12.1.0.2.0) + SDK, then cx_Oracle. When trying to connect to the DB it says
cx_Oracle.DatabaseError: ORA-03134: Connections to this server version are no longer supported.
so I t... |
how to make a python script run repeatedly
Question: I have a simple script which saves some values to a database , I also have a
window built in Tkinter. So basically my problem is I want the savebase()
function to be continuously called upon, till the window remains open. How can
this be done ?
Till now I'm able jus... |
Compare 2 seperate csv files and write difference to a new csv file - Python 2.7
Question: I am trying to compare two csv files in python and save the difference to a
third csv file in python 2.7.
import csv
f1 = open ("olddata/file1.csv")
oldFile1 = csv.reader(f1)
oldList1 = []
for ... |
Trouble reading in Unicode strings from CSV file to DictReader in Python
Question: I have a CSV file I'm trying to read in using DictReader.
But doing just this:
with("BeerRatings.csv", "r", "utf-8") as f:
reader = csv.DictReader(f)
for line in reader:
print line
gives ... |
Error in executing .jar file from a Python script called from another Python script, as a subprocess
Question: This is in extension to a resolved post that I had posted
[here](http://stackoverflow.com/questions/30766563/error-in-executing-a-jar-
file-in-remote-machine). I have a `python script` which has the following
... |
Python: Urllib proxyhandler error
Question: So I'm fairly new to using the urllib.request library and I'm trying to run a
proxy through proxy handler, however I keep getting this error message
assert hasattr(proxies, 'keys'), "proxies must be a mapping"
AssertionError: proxies must be a mapping
... |
How to create a module[qpython3]
Question: Noob alert!
I'm wondering how you go about importing a module(one made in qpython)? I've
tried making a new folder and adding a setup.py then trying to import but just
get error about module not found(or something)..
Thanks in advance
Answer: Your folder must to consist in... |
How to execute Python code generated by Blockly right in the browser?
Question: I was following the example [Blockly Code
Generators](https://developers.google.com/blockly/installation/code-
generators) and was able to generate Python codes. But when I run the Python
code, I get an error. It seems the error is 'eval(co... |
Create Popup in MapMarkerPopup on the python-side(not in kv file) in kivy-Garden-Mapview
Question: I went to the [MapView-
Doncumentation](http://mapview.readthedocs.org/en/latest/#) and also to the
[Source code](https://github.com/kivy-garden/garden.mapview) but this doesn't
seems to help much.
I created this templet... |
How to minus time with Python
Question: I'd like to get the time before X seconds before `datetime.time.now()`. For
example, if the `time.now()` is `12:59:00`, and I minus `59`, I want to get
`12:00:00`.
How can I do that?
Answer: [You can use time
delta](https://docs.python.org/2/library/datetime.html#timedelta-obj... |
Python Pandas to_sql, how to create a table with a primary key?
Question: I would like to create a MySQL table with Pandas' to_sql function which has a
primary key (it is usually kind of good to have a primary key in a mysql
table) as so:
group_export.to_sql(con = db, name = config.table_group_export, if... |
Type error in python program
Question: I always get a Type Error when I run the following python code (abc.py) as
follows:
./abc.py activatelink alphabeta
Type Error: ['alphabeta']
My code:
#!/usr/bin/python
import urllib2
from urllib2 import URLError
from urllib... |
Issue with large files in Python 2.7
Question: I am currently experiencing an issue while reading big files with Python 2.7
[GCC 4.9] on Ubuntu 14.04 LTS, 32-bit. I read other posts on the same topic,
such as [Reading a large file in
python](http://stackoverflow.com/questions/19796402/reading-a-large-file-in-
python) ,... |
Importing Python libraries in Openshift cron jobs
Question: I have a script in .openshift/cron/daily that looks like this
#!/usr/bin/python
import sys
import os
sys.path.append(os.environ['OPENSHIFT_REPO_DIR'])
import EmilyBlogModel
EmilyBlogModel.Poll()
EmilyBlogModel.py is in ... |
Update label's text when pressing a button in Kivy for Python
Question: Here is my code: I want to make a game where the main_label changes text when
you press a button but I've looked everywhere for a week and still don't
understand how to do it. I looked on Kivy's website but I don't understand. As
you can see I'm ne... |
Run python code on a folder of XMLs
Question: I would like to be able to run the following code on a folder of XML files
rather than a single one. I also do no want to change the `xmlfile =
'test.xml'` line 100+ times for each file.
This is the example `elementTree` code that I found and am testing.
fro... |
Map step that involves subprocess with pipe fails in PySpark
Question: My goal is to to read binary (gpg-encrypted) files on hdfs consisting of csv
data. My approach -- following [this
answer](http://stackoverflow.com/a/30765052/2708667) \-- has been to define a
Python function to read and decrypt a gpg file, yielding ... |
pcap file viewing library in python 3
Question: I'm looking at trying to read pcap files from various CTF events.
Ideally, I would like something that can do the breakdown of information such
as wireshark, but just being able to read the timestamp and return the packet
as a bytestring of some kind would be welcome.
T... |
Python and conflicting module names
Question: It seems that if a file is called `io.py` and it imports `scipy.ndimage`, the
latter somehow ends up failing to find its own submodule, also called `io`:
$ echo "import scipy.ndimage" > io.py
$ python io.py
Traceback (most recent call last):
Fi... |
Abbreviation Reference for NLTK Parts of Speach
Question: I'm using nltk to find the parts of speech for each word in a sentence. It
returns abbreviations that I both can't fully intuit and can't find good
documentation for.
Running:
import nltk
sample = "There is no spoon."
tokenized_words = nl... |
JSON in Python: encoding issue on OS X, no issue on Windows
Question: I have a file `log.json` that contains one line:
{"k":"caf\u00e9"}
I run the following code on Windows 7 SP1 x64 Ultimate:
import json
a = json.load(open('log.json', 'r'))
f = open('test.txt', 'w')
f.w... |
How to index an array value in a MATLAB-Function in Simulink?
Question: I'm using a matlab-function in simulink to call a python script, that do some
calculations from the input values. The python-script gives me a string back
to the matlab-function, that I split to an array. The splitted string has
always to be a cell... |
Using sympy on strings
Question: I have a file with some equations. I want to solve them using sympy. I can use
open('problems.txt',mode='r') to open the file. But how to proceed with sympy?
I'm getting following error
> sympy.core.sympify.SympifyError: Sympify of expression 'could not parse
> 'x+x+x-x = 18 + 4'' fail... |
Json to CSV using python and blender 2.74
Question: I have a project in which i have to convert a json file into a CSV file.
The Json sample :
{
"P_Portfolio Group": {
"depth": 1,
"dataType": "PortfolioOverview",
"levelId": "P_Portfolio Group",
"pat... |
Python: [Errno 2] No such file or directory:
Question: I have imported Python Project in Eclipse. When i run the script on mac
machine i am getting error as below:
`[Errno 2] No such file or directory: '/Users/noimac-
mini4/Documents/workspace/MobileAutomationPy\\..\\..\\..\\..\\'`
what could be possible cause of err... |
How to show minor tick labels on log-scale with Matplotlib
Question: Does anyone know how to show the labels of the minor ticks on a logarithmic
scale with Python/Matplotlib?
Thanks!
Answer: You can use `plt.tick_params(axis='y', which='minor')` to set the minor ticks
on and format them with the `matplotlib.ticker` ... |
Python argv and cmd
Question: I'm trying to make a Python program that can correct exams automaticly, I have
extra time and don't wanna wait for my teacher to correct them manually...
Annyways when i use python argv like this:
import sys
def hello(a):
print(a)
a = sys.argv[1:]
... |
only length-1 arrays can be converted to Python scalars using int function
Question: I currently got an array in python which is an element of a dictionary and, in
python console, looks like this:
TUMEC['spans'][0]
array([0. , 0.25, 0.5, 0.75, 1.])
I want to pass the whole array to a function b... |
IntelliJ/Webstorm not finding import reference
Question: I have the following project structure:
* root
* src
* scripts
* main.js
* foo.js
Inside of my `main.js` file, I'm importing `foo.js` like so:
import 'src/scripts/foo.js'
When I click on the import statement a... |
Issue with UDF on a column of Vectors in PySpark DataFrame
Question: I am having trouble using a UDF on a column of Vectors in PySpark which can be
illustrated here:
from pyspark import SparkContext
from pyspark.sql import Row
from pyspark.sql.types import DoubleType
from pyspark.sql.function... |
Converting list to array with NumPy asarray method
Question: I try get mean from csv line. I get data from csv in string list, further i
convert it to array with numpy. Its work perfect when i try plot some
graphics. But when i calculate mean i get some errors with my data.
If i use NumPy i get:
TypeErr... |
Extract substrings in python
Question: I want to parse a string to extract all the substrings in curly braces:
'The value of x is {x}, and the list is {y} of len {}'
should produce:
(x, y)
Then I want to format the string to print the initial string with the values:
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.