Questions tagged [python]

Python is a high-level interpreted dynamic, strongly typed, object-oriented, multipurpose programming language, designed to be quick (to learn, to use, and to understand), and to enforce a clean and uniform syntax. Two similar but incompatible versions of Python are in use Python 2.7 and 3.x. For ...

0
votes
0answers
2 views

Can't set a variable outside of class scope using global

I'm developing a python program that requires other threads to access the Pool and I used this method as I always use: Variable scope outside of classesBut when I run the code it gives an error even ...
0
votes
0answers
9 views

How to determine when stdout is empty? (Issue with stdout and readline())

I am having issues with my code hanging in the for loop of this function. This function is called as a separate thread in a larger main script. After a user input, the main script sets self....
0
votes
2answers
32 views

Random Word in Dictionary

How might I get a python function to, every time it is called, pick a random five-letter word from the English dictionary?
-1
votes
0answers
10 views

Attempting to re-instantiate class object doesn't work

I have read up a fair bit on this but I can't figure out how to make it work. I tried defining the call method first in my app, but I couldn't get it to work.Essentially, after the code ends and the ...
0
votes
0answers
5 views

Python/Django - How to annotate a QuerySet with a value determined by another query

Django 1.11, python 2.7, postgresqlI have a set of models that look like this:class Book(Model):released_at=DateTimeField()class BookPrice(Model):price=DecimalField()created_at=...
0
votes
0answers
12 views

Pandas Graph Bar and Line plot problems

I am Trying to plot a line graph on top of a bar plot for analysis from a dataframe. Every time i try and add the line graph, the y axis on the right goes haywire and the bar plot headers on the x ...
0
votes
0answers
7 views

pipeline+SelectFromModel+LinearSVC+RandomForest gives me TypeError: not all arguments converted during string formatting

I'm using the SelectFromModel function with limearSVC to do feature selection before fitting a random forest predictive model. The traininf dataset X is like this:col1 col2 col3 col4 col5 ...
0
votes
2answers
18 views

Removing a concrete value from a set using function [duplicate]

(Newbie question) I want to write a Python program that removes a concrete item from a set if it is present in the set.When the set is predefined, the code goes like this:set={1,2,3,4,4,5,6,10}...
0
votes
0answers
7 views

Python 3 sys.version_info casting to a dict (_asdict)

I am new to Python and just messing around with it. Is there something unique about sys.version_info that means it doesn't return a proper namedtuple and therefore doesn't have the _asdict function? ...
0
votes
1answer
8 views

How to write a text file from Dictionary, where each key is a new line?

here is my code:#creating a list of tweets ID and a dictionary with the valuestweet_ids=list(df1.tweet_id)tweet_data={}for tweet in tweet_ids[:5]:try:tweet_status=api....
0
votes
2answers
18 views

Python argparser not recognised

I am trying to write a python script that takes one argument from the user.I want to throw a message if the input is not part of the list of possible inputs.However, I get the "Unknown direction..." ...
-1
votes
0answers
17 views

Iteration with linspace through For loop

I have created a class capacity, which makes some calculation by iterating valuex through a for-loop. There is nothing wrong with calculation process.I only need to break or stop equation, when this ...
1
vote
1answer
21 views

Why does accessing columns of a pandas dataframe with .loc[] produce duplicate rows?

Why is .loc[] producing duplicate rows in my DataFrame? I'm trying to select a few columns from m3, a DataFrame with 47 columns,to create a new DataFrame called output. The problem: after accessing ...
0
votes
1answer
12 views

ptest on groupby() python

I've a dataframe as below:Region VotesA 23B 26A 32B 46A 32B 24I calculated mean of votes for region A and B ...
0
votes
1answer
17 views

Is it acceptable to have python package names with numbers in it?

I've seen PyPI distribution names as well python package names with numbers in them. For example flake8 is one example, where you also import with import flake8.According to PyPI and PEP standards, ...

153050per page
angop.ao, elkhabar.com, noa.al, afghanpaper.com, bbc.com, time.com, cdc.gov, nih.gov, xnxx.com, github.com,