text stringlengths 226 34.5k |
|---|
Editing csv file Python 3 - matching file content to the print output
Question: I am having an issue with getting the contents of created csv file to show up
as the print output.
Code:
import csv
with open('test.csv', 'w', newline='') as csvfile:
filewriter = csv.writer(csvfile, delimit... |
Printing Python output in HTML
Question: I have a Python script (which works and outputs correctly when ran) but I am
having trouble posting the output to a HTML page.
No errors are being shown.
I am new to Python.
**PYTHON**
import urllib2
def internet_on():
try:
response... |
creating MLP in python showing error
Question: Iam a newbie in neural networks while creating MLP in python using opencv
3.1.0 error pops.The code is import cv2 import numpy as np import glob
print 'Loading training data...'
e0 = cv2.getTickCount()
# load training data
image_array = np.z... |
How can I create folder in importing process [python]
Question: How can I create a class that creates directories for both with 1. Initial
values and 2. input arguments ?
This is my code mypath.py
import os
myroot = 'D:\\pet'
class path(object)
dog = os.path.join(myroot, 'dog')... |
Check if string in the exact form of “<int1>,<int2>” in Python, without using regex, or try/catch
Question: I'm converting a string of two integers into a tuple. I need to make sure my
string is formatted exactly in the form of:
"<int1>,<int2>"
This is not a duplicate to an earlier question. Since ... |
What does "see docstring of the instance object for more information" mean
Question: I feel like this is a dumb question, but when I'm in an IPython notebook and I
do help on some numpy/scipy function, like say stat.norm.rvs, it frequently
says, about *args and **kargs, "see docstring of the instance object for more
in... |
Extracting a string from a text file in python 2.7.5
Question: Hello I am new to python, and I hope you can help me. I have a text file (call
it data.txt) with data on gene number with corresponding rs number and some
distance measure. The data looks something like this:
rs1982171 55349 40802
... |
Error running Django in PyCharm
Question: I am a Python noob and just recently cloned a Django project into PyCharm. I
got it all set up with Django support and located the settings.py and
manage.py but I get these traceback errors when I tried running the project.
Unhandled exception in thread started b... |
Python has modules, what does c++ have?
Question: Coming from programming in python, I am familiar with modules. What is the
equivalent in c++?
Answer: The concept in c++ is more complicated than it is with python, from what I
remember of python, a module will work without having to take care of the
architecture the ... |
Python output not showing on Mac Terminal
Question: I have a very simple code that I wanted to execute;
#!/usr/bin/env python
import sys
def Hello(name):
name = name + '!!!!'
print('Hello', name)
if __name__ == '___main___':
Hello(sys.argv[0])
and on th... |
List manipulation code optimization with Python
Question: I have a simple code to group and calculate content of the list. I'm concerned
of the time it takes to complete the job. With less than 100 items it is fast
enough, but several hundreds items make my Mac to scream. And I have up to
10000 items on a list from rea... |
BeautifulSoup not showing Korean letters properly
Question: I'm a newbie in Python who is learning parsing with BeautifulSoup.
This is my code,
#-*- coding: utf-8 -*-
import urllib
from bs4 import BeautifulSoup
soup = BeautifulSoup(urllib.urlopen('https://news.google.com/news/secti... |
How do I pass variables to shell functions in Python?
Question: I would like to write a Python script to automate the process of adding the
dependencies of a npm package to my Open Build Service project. I have a shell
function:
function cpobsn {
cdobsa
mkdir nodejs-$1
cd nodejs-$... |
Jupyter shows plot without plt.show()
Question: I am using the Jupyter notebook with Python 2.7. Importing matplotlib like
this:
%matplotlib inline
import matplotlib.pyplot as plt
But I have observed one thing. When I use Python in Spyder I always have to
use the `plt.show() commando at the... |
Pyrhon variable working outside of function, but not inside
Question: I have an issue where I am trying to copy feature classes into a geodatabase.
I am looping through all the feature classes in the folder and copying only
the polygon feature classes. My problem is, that when I copy the first polygon
feature class it ... |
create new xlsx file with python equals to another one
Question: I have one xlsx file and I want to create with python script another xlsx file
equal to the first one. How can I do? Have you an example script?
Answer: shutil can hep you do this.
from shutil import copyfile
copyfile(src, dst)
... |
Coloring axvspan from range of colors (Python)
Question: **Background**
I am trying to plot consecutive colored areas in **Python** using
**matplotlib**. I use (imagine i being some iteration variable)
axvspan(from_x[i], to_x[i], color=my_color[i])
to plot this.
Now, I need a general way to say "... |
How to log in and auto fill values into a 'drupal form' from an 'excel file'?
Question: So, there is this website where I have to log in and insert values in the _add
content->person roles_ and I have to take values from an excel file. I tried
entering the values in the database directly but got nowhere. The database i... |
Extract data from json stock file using python
Question: How do I extract the data from that URL? I only want to print out all the
'value'
import urllib
import re
import json
htmltext = urllib.urlopen("http://www.bloomberg.com/markets/api/bulk-time-series/price/AXP%3AUS?timeFrame=1_MONTH... |
Python 3 - Parse JSON from multiple API requests into a list and output to a file
Question: How do I...
1) Parse JSON objects from API queries in Python 3
2) Parse multiple requests into a list, and
3) Output the list into a JSON file
Answer: I prefer using [`requests`](http://python-requests.org/) for all API
pro... |
Clean up code or to find a more efficient ways to write some of this code.
Question: I am looking to see if I can find a more efficient way to write this. The
problem with csv reader is that when you write the output to standard out it
tosses additional single quotes around it. Changing the quotes to none didn't
help b... |
making windrose from my own data
Question: I am trying to make a wind rose from a series of windspeed and direction
values. I have an idea of how to write the raw program for doing this as shown
below:
from windrose import WindroseAxes
from matplotlib import pyplot as plt
import matplotlib.cm as ... |
How to store time without date in Python so it's convenient to compare?
Question: I have a simple task of storing a time in server's timezone and then comparing
if current time if after or before the saved time.
I tried to store the time as a "Jan 1st 2008" date with the time I need. The
problem is a daylight saving t... |
Converting Data From Serial Port to Display as Decimal in Python
Question: I am starting a program that reads data from a radio receiver. The data is 6
bytes long and updates every 1 second. The program reads the serial port USB
data, but the data is in some format that does not display correctly. What I
do know is tha... |
Create and insert a strftime-object for mysql datetime-field
Question: I have a database which is supposed to be moved to a new one. My idea is a
python script that reads all old entries, converts them in the new format and
sends them to the new database. The problem is that the date(time) is stored
differently. In the... |
Unable to access wikipedia API due to SSL-certificate error
Question:
import requests
spiders = requests.get('https://en.wikipedia.org/w/api.php')
print(spiders)
With above code I am getting following error:
Traceback (most recent call last):
File "C:\Python\lib\site-package... |
Transposition Cipher in Python
Question: Im currently trying to code a transposition cipher in python. however i have
reached a point where im stuck.
my code:
key = "german"
length = len(key)
plaintext = "if your happy and you know it clap your hands, clap your hands"
Formatted = "".join(pla... |
Download Google Spreadsheet and save as xls
Question: Am trying to write python procedure to download a spreadsheet from google
spreedsheets and save it as .xls. here is my code
import os
import sys
from getpass import getpass
import gdata.docs.service
import gdata.spreadsheet.servic... |
python re.findall vs re.sub
Question: Please explain me why I get different results with using re.find and re.sub
The string which I parse:
GRANT USAGE ON *.* TO 'testuser'@'10.10.10.10' IDENTIFIED BY PASSWORD '*A78AF560CD6F8FEA4DC8205299927B6CB1B1F56A'
Code:
import re
S="G... |
Rock Paper Scissor Python
Question: I'm Learning Python and coded rock, paper and scissor game.
I'm using IDLE in Ubuntu for this. The code has compiled fine but still i'm
unable to get this running. IDLE is running fine in this system. PLease help
me resolve this.
Thanks in advance
#!/usr/bin/env pyth... |
Using a function to get column names Sqlite3
Question: I have a short question for one of my classes; it involves building a function
in python that takes a sqlite database name and a table name as arguments, and
returns the column names inside this table.
So far I have done the following:
#!/user/bin/e... |
How to find the middle value of an integer without converting it to a string using Python3?
Question: While solving the next [smallest palindrome
problem](https://github.com/harishvc/challenges/blob/master/string-next-
palindrome.py), I had to convert an integer to a string so I can reverse and
find the middle value. T... |
Using Hive functions in Spark Job via hiveContext
Question: I am using Hive 1.2 and Spark 1.4.1. The Following query runs perfectly fine
via Hive CLI:
hive> select row_number() over (partition by one.id order by two.id) as sk,
two.id, two.name, one.name, current_date()
from avant_source.one one ... |
How to Replace variable value in string python?
Question: I working on python based project where formula's are stored in dB. My script
will read the formula's from a particular column and stored in list . For Eg
formula[0] = "round(float(latitude[:2]) + (float(latitude[2:]) / 60)"
formula[1] = "roun... |
Create mocked http session with scapy python
Question: How can i create a HTTP session and save the packets of it? i have got this
code:
import logging logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
from scapy.all import *
get='GET / HTTP/1.0\n\n'
ip=IP(dst="www.google.com")
port=RandNum(1024,65535)
S... |
Python method invovation , missing parameter
Question: Hi i'm trying to implement a profiling system so that as soon as the user logs
in, the student is identified and pulls information from the student model and
returns it to the homepage and probably every other page within the system. It
will also append the student... |
python - Substrings which contain only 'a', 'b' or 'c'
Question: I was coding for [this
problem.](https://www.hackerearth.com/problem/algorithm/substring/)
> Maggu has just joined play school. His teacher taught him A,a,B,b,C,c. He is
> much fascinated with these letters and now he is looking only for those
> strings ... |
Search word in python
Question: I have text file, I am searching for specific word "Belief". I want the word
to be shown in red colour if it was found.
searchfile = open("demo.txt", "r")
text=input("Enter search word :")
for line in searchfile:
if text in line:
print(line)
... |
Multiple .replace() ?? and understanding the "u" which gets added to record from excel file (Python)
Question: I need some help with this code:
import pyexcel as pe
import pyexcel.ext.xls
import pyexcel.ext.xlsx
def randStrings(excelFile1,excelFile2):
getNameList = pe.get_sheet(f... |
Logging values of variable with kivy.logger
Question: I want to log the value of a variable using kivy.logger in file.
I added the following lines to my code:
from kivy.logger import Logger
Logger.debug('EZS-2G: element: %s', str(element))
the following line appears in my IDE (Atom):
... |
Interrupt a blocking evdev reading
Question: I have a module that captures all reads from a barcode scanner. My problem is
that I can not close it properly. After sending a KeyboardInterrupt or
SystemExit signal, it stops only when I scan a barcode.
I tried to add this method to the BarcodeScanner class, but it still ... |
Python - Pymediainfo Module [Error 126] The specified module could not be found
Question: The error I'm receiving is this:
Traceback (most recent call last):
File "C:\Users\Me\test3.py", line 4, in <module>
media_info = MediaInfo.parse("video.mp4")
File "C:\Python27\lib\site-packages\pymed... |
Compare some text with difflib and openpyxl Python
Question: I want to find some words in some cells of a certain column. Those words (use
to compare) are stocked in another sheet. I'm trying to use a loop to choose
all the cells from this column.
I got this code :
import difflib
import ope... |
How can I crawl only a particular domain using Python?
Question: I need to start with a domain and extract all links from the site, then
continue on and extract the links from those links. However, I am only
supposed to traverse the links that are part of the given domain. I'm using
BeautifulSoup. The only way I can th... |
Python BeautifulSoup can't read div tag
Question: I'm trying to get products for a project i'm working on from this
page:[lazada](http://www.lazada.co.id/catalog/?q=note%202)
[page ispection](http://i.stack.imgur.com/lR24T.png)
using :
from bs4 import BeautifulSoup
import urllib
... |
Error finding current time in Python
Question: I am trying to implement this time class to find the current time. I am
getting wrong time. Can someone please take a look what am I doing wrong here?
import time
import datetime
class Time():
def __init__(self):
currentTime = time.t... |
3D histograms and Contour plots Python
Question: I have a problem with contourf function of matplotlib. I have a txt data file
from which I am importing my data. I have columns of data (pm1 and pm2) and I
am performing a 2D histogram. I want to plot this data as a 3D histogram and
as a contour plot to see where is loca... |
python Selenium options drop down
Question: I am new to python. I have a code in R that I am trying to replace with a
python script. I am running into issues getting python to select a value from
a drop down menu.
This is the code in R that worked:
remDr$findElement(using = 'xpath', "//select[@id = 'gro... |
Python regexp \n issue
Question: This searched ok:
>>> re.search(r'(.*?)\r\n(.+?)\r\n', 'aaa\r\r\nbbb\r\n').groups()
('aaa\r', 'bbb')
But when I replace one of three `b` to `\n` it not searched:
>>> re.search(r'(.*?)\r\n(.+?)\r\n', 'aaa\r\r\nb\nc\r\n').groups()
Traceback (mos... |
Performance Issues With Natural Language Processing in MATLAB
Question: For a class, I'm processing raw text documents (our examples include novels
that can be downloaded from the Gutenberg project) and turning them into a
dictionary data structure. For each word, I need to know which paragraph(s) it
occurs in, and how... |
Python. Using CSV to read a file. Syntax Error
Question: The following script shows syntax error at line "with open..."
#!/usr/bin/python
import fileinput;
import csv;
def read_csv_file ( file_name ):
with open('file.csv', 'r') as my_csv_file:
reader = csv.... |
How to mock a BulkWriteException in python?
Question: I need to get the information contained in the exception. This is the code I
use.
try:
result = yield user_collection.insert_many(content, ordered=False)
except BulkWriteError as e:
print (e)
And in my test when I get into th... |
Indentation error in Python 2.7
Question: I'm getting an indentation error in this line of code (it's a comment with all
spaces, no tabs), hope you can help me with this :)
import os
import socket
import connection
from constants import *
"""
get_file_listing lists the files i... |
What does Python string.maketrans("","")
Question:
string.maketrans("","")
gives
\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13
\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f !"#$%&\'()*+,-./0123456789:;<=>?
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghi... |
Using Python Tkinter on Beaglebone: Display Flicker
Question: Below is the code for displaying data on a monitor using Python and Tkinter on
BeagleBone. It works great, but the text which displays the data flickers. Any
ideas why?
#!/usr/bin/python
import alsaaudio as aa
import audioop
i... |
django module import error - python 2.7 vs python 3.4
Question: I have installed django1.9 with python 2.7. But now I want to use it with
python3.4. Hence I have modified symbolic link of python to python 3.4 like
below.
sudo ln -s /usr/bin/python3.4 /usr/bin/python
Because same django works with p... |
Main axis are not shown when using grid
Question: I want to plot two graphs into the same figure with two different y-axis. In
addition to it, I would like to add a grid and then save the plot as pdf.
**My problem** is that - while the grid is drawn correctly - the main axis are
not shown anymore. How can they be plot... |
Changing pixel color value in PIL
Question: I need to change pixel color of an image in python. Except for the pixel value
(255, 0, 0) red I need to change every pixel color value into black (0, 0, 0).
I tried the following code but it doesn't helped.
from PIL import Image
im = Image.open('A:\ex1.jpg... |
Most efficient (and pythonic) way to count False values in 2D numpy arrays?
Question: I am trying to count `False` value in an `np.array` like this:
import numpy as np
a = np.array([[True,True,True],[True,True,True],[True,False,False]])
I usually use this method:
number_of_false=... |
aws depoylment issue while restarting nginx
Question: I am using favfile(<https://ashokfernandez.wordpress.com/2014/03/11/deploying-
a-django-app-to-amazon-aws-with-nginx-gunicorn-git/comment-
page-1/#comment-100>) to deploy a django app. But stuck somewhere.Please help,
a link has been provided for fabfile.
... |
Python: How to generate a random phone number?
Question: Not a duplicate of [Making random phone number xxx-xxx-
xxxx](http://stackoverflow.com/questions/26226801/making-random-phone-number-
xxx-xxx-xxxx)
My project uses [python-phonenumbers](https://github.com/daviddrysdale/python-
phonenumbers) and [django-phonenumb... |
Python argparse check choices before type
Question: I'm trying to enable a user to pass in a function name. For some reason it
seems that argparse performs the type check/conversion BEFORE it checks the
choices. Is this a bug? Best thing to do?
import argparse
def foo():
return 'foo'
... |
Issues converting larger HTML files to docx in pypandoc (pandoc)
Question: My question is related to [How to increase heap memory in pandoc
execution?](http://stackoverflow.com/questions/30704736/how-to-increase-heap-
memory-in-pandoc-execution), but adds a Python-specific component.
Background: I'm trying to generate... |
Python child logger should report back to root logger instead of applying its own logging configs
Question: As mentioned here <http://stackoverflow.com/a/4150322/1526342>. When logging
to child logger, it will pass on the message to its parent, and its parent
will pass the message to the root logger. Now considering th... |
Jupyter error: "No module named jupyter_core.paths"
Question: Trying to open Jupyter Notebook (OSX 10.11.4) I get the following error:
$ jupyter-notebook
Traceback (most recent call last):
File "/usr/local/bin/jupyter-notebook", line 7, in <module>
from notebook.notebookapp import main
... |
out of memory panic while accessing a function from a shared library
Question: I'm trying to build a sample shared object library using Go. The code compiles
(using the command `go build -o libsample.so -buildmode=c-shared .`), a shared
object library is built successfully - but while accessing the exported method
via ... |
Python os.walk and symlinks
Question: While fixing one user's [answer on
AskUbuntu](http://askubuntu.com/a/754931/295286) , I've discovered a small
issue. The code itself is straightforward : os.walk , recursively get sum of
all files in the directory.
But it breaks on symlinks :
$ python test_code2.py ... |
Python MySql query silently failing
Question: I've got a MySql database (running using the stock Docker image) and it
contains a table defined like this:
CREATE TABLE `Edits` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`context` varchar(255) NOT NULL,
`field` varchar(255) NOT NULL,
`v... |
wrap boost::optional using boost::python
Question: Is there a way to wrap `boost::optional<T>` type object to expose it via
`boost::python::class_` (used from `BOOST_PYTHON_MODULE`)
struct Foo
{
boost::optional<int> bar;
};
BOOST_PYTHON_MODULE(module_name)
{
class_<F... |
Please point out my mistake in the following program
Question: Here m trying to extract a list of blacklist IP from a specific site and
trying to make an excel sheet of the following fields : IP , date ...... New
updated code is :
import xlwt
import urllib
def Bl():
link = 'https://w... |
How to stream images to the browser with Django
Question: Forgive me if I am using these terms incorrectly, I'm pretty new to the
concept of streaming and I haven't found many resources in Googling that
talked about the best use cases for streaming.
What I have right now:
Browser makes a requests for an image to a Dj... |
CUDA-Python: How to launch CUDA kernel in Python (Numba 0.25)?
Question: could you please help me understand how to write CUDA kernels in Python?
AFAIK, **numba.vectorize** can be performed on _cuda, cpu, parallel(multi-
cpus)_ , based on **target**. But _target='cuda'_ requires to set up CUDA
kernels.
The main issue ... |
Python: copy and paste files based on paths in two csvs
Question: I have two csv files, one with a list of paths for source files, the second, a
list of paths for where to copy the files to. Both files have the same number
of elements and each source file is only copied once.
How would I load the .csv files (Pandas? N... |
Cannot add comment to SQL db in python Flask app
Question: I am new to programming and have setup a small website with a comments section
on pythonanywhere.com, relaying heavily on their tutorial. But when I post a
comment in the form, the comment is not added to the database and for some
reason the program redirects m... |
Django rest framework extended user profile
Question: I recently discovered DRF and I'm lost with the quantity of views, viewsets
and other possibilities.
I have a Python3/Django 1.8 application with an extended user profile:
from django.db import models
from django.contrib.auth.models import User
... |
How to set picture display location in ipython/jupyter notebook cell?
Question: I try to plot multiple pictures in the ipython cell for comparison. Here is
what I have got from the below nodes [](http://i.stack.imgur.com/NsX7d.png)
import... |
IndexError: list assignment index out of range in python 2.7.11
Question: I was just solving a problem using python, and my codes are:
from math import sin,pi
import numpy
import numpy as np
import pylab
N=20
x = np.linspace(0,1, N)
def v(x):
return 100*sin(pi*x)
... |
Continue the script if an element is not found using selenium in Python
Question: I am having a trouble trying to figure out how to continue the script if an
element is not found using selenium in Python.
This code cycles through reports, finds the refresh button and then clicks on
the download the button. The only pr... |
Python/Tkinter: why does the .get method of IntVar shows same value when clicking different radiobuttons?
Question: ## Brief overview of the program:
1. When launching script, the dialog window is appearing and asking you to select directory path (class `MyApp`)
2. When selected - one needs to push the "Start Moni... |
Module not being set up properly
Question: New-ish to python, but I though I had everything set up right. When I run
`python -m unittest test.unit.test_oyez_case`, I get `AttributeError: 'module'
object has no attribute 'test_oyez_case'`
Sorry this is a frequent question, none of the responses were helpful to me
Here... |
Loading, querying SQL Compact (SQLCE) 4.0 database files through Python
Question: I am trying to load table from a compact sql database (.sdf file format) into
Python (3.5.1). Here is what I have been playing around with:
import adodbapi
file="C:\\TS\\20160406_sdfPyt\\HC.sdf"
connstr = 'Provider=... |
Python: How to get the next day of unix timestamps at 00:00 and 23:59?
Question: I have a matrix like this in my code with unix timestamps:
event_sequences = [
[1368136883, 1368137089], #The first event is never empty
[1368214777, 1368214966],
[],
.... There are the perfect num... |
python script for enquiring the version of multiple operating systems
Question: I am new to python, looking to write a script which would ssh to about 1000
hosts from a jump server and Output should contain the hostname and version of
the operating system. Redhat 5.0 or 6,0 etc and I have list of all the hosts
and so t... |
Python CGI script doesn't run
Question: I'm trying to run a simple python cgi script on apache webserver. But the
output when I try access (<http://localhost/cgi-bin/environment_key.py>), it's
just the python code... the file doesn't run. I tried other solutions that I
found in the stackoverflow to fix this, but it doe... |
how to extract python data frame from JSON string
Question: I've got the following JSON string in a txt file and I'm trying to extract a
data frame from the 'visualLogs' variable. I can read the JSON string in and I
can access the visualLogs list, but I have failed all day long to convert this
into a 9 column data fram... |
Python, How to organize a big function that relies on many external data to work
Question: Question: How to organize a big function that relies on many external data to
work. should I declare a class and contain those external data? or should I
keep the big function and its data in one file? Or there are better ways of... |
why will multiprocess spawn multi threads in every process?
Question: I am using python
[`multiprocessing`](https://docs.python.org/2/library/multiprocessing.html),
here is a simple example:
from multiprocessing import Pool
import time
import signal
def process(_id):
time.sleep(2... |
python garbage collection after start process using multiprocess
Question: I test the gc behavior that python perform after start process using
multiprocess:
from multiprocessing import Process
import time
class A(object):
def __del__(self):
print 'deleting'
def ... |
Python Matplotlib - saved images getting overwritten while using for loop
Question: I am having one big list which has six small list's. These six small lists are
used as the slice values while generating a pie chart using matplotlib.
f_c = [[4, 1, 0, 1, 0],
[4, 1, 0, 1, 0],
[4, 1... |
How to Multithread functions in Python?
Question: I have made 2 functions in Python that have loop command. For making process
faster, i wanted to multithread them.
For example:
def loop1():
while 1 < 2:
print "something"
def loop2():
while 5 > 4:
print "... |
Tkinter - Sorting the checkboxes and printing if they're clicked
Question: I'm learning Tkinter and have two questions.
[1st one answered in the comment section]
1 - Why do the items in the dictionary are not printed in the correct order?
If you delete the "grid" part from the Button, you may see that they are not
or... |
Capture cout from c++ by subprocess in my pythonscript
Question: in my django python script i run my .cpp program. I want to capture my
standard output (cout) in c++ by subprocess in python. In c++ I tried to make
a stream which buffers all of my couts and return it in main(), but the only
value I can return in main fu... |
Overwriting/clearing previous console line
Question: My problem is, that I want to be able to overwrite/clear previous printed line
in python console. This question has been asked many times ([Python - Remove
and Replace Printed items](http://stackoverflow.com/questions/5290994/python-
remove-and-replace-printed-items)... |
Scikit-image: cannot import name 'label'
Question: I have some scripts that use `skimage.measure.label`. On my old laptop (Debian
7, Python 2) these scripts worked perfectly. Recently, when I got a new
laptop, I moved to Debian 8 and Python 3. Now these scripts cannot import
`skimage.measure.label`:
File... |
Python error 'int' object has no attribute 'shape'
Question: Using the example below, `sklearn` with Python 3.5:
from sklearn import tree
features = [[140,1], [130,1], [150,0], [155,0]]
labels = [0,0,1,1]
clf = tree.DecisionTreeClassifier()
clf.fit(features, labels)
print(clf.pre... |
Python Sql Outputs
Question: When running the following code:
import sqlite3
conn = sqlite3.connect('example3.db')
c = conn.cursor()
c.execute('''
SELECT name FROM sqlite_master WHERE type="table" ORDER BY name;
''')
print c.fetchall()
conn.commit()
conn.close... |
Why do some Python packages have repetitive directory names?
Question: The question of what the directory structure of a Python project has been
asked a number of times on Stack Overflow (e.g.
[here](http://stackoverflow.com/questions/193161/what-is-the-best-project-
structure-for-a-python-application),
[here](http://s... |
pip gmane can't import
Question: I have already install the gmane, for sure i have run the upgrade.
pip install gmane --upgrade
And then it show me those:
> 'Requirement already up-to-date: gmane in ./lib/python2.7/site-packages'
>>> import gmane
It's shows me these errors:
... |
Difference between dir(string) and dir(someString) in Python?
Question: I just start learning programming with python. As I learn if I want to list
all string modules I wrote:
import string
print dir(string)
Result:
> ['Formatter', 'Template', '_TemplateMetaclass', '**builtins** ', '**doc** ',... |
List Index Error on Python
Question: Im writing a program to try to calculate how many times the most repeated word
in a list occurs. I keep getting an error that says: index error. Even though
when I print the list of my word_list, it shows there are 108 elements. Could
someone point me in the right direction as to wh... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.