Questions tagged [python-3.x]

For questions about Python programming that are specific to version 3+ of the language. Use the more generic [python] tag if your question is not version-specific. Use the [python-2.x] tags for Python 2 questions.

Filter by
Sorted by
Tagged with
0
votes
1answer
11 views

Read some specific lines from a big file in python

I want to read some specific lines from a large text file where line numbers are in a list, for example: list_Of_line =[3991, 3992, ...]. I want to check whether there is the string "this city" in ...
0
votes
0answers
6 views

Pywin32 Error: com_error: (-2146959355, 'Server execution failed', None, None)

I am attempting to open Excel on my computer (Windows, 64-bit) using Pywin32, but it is not working. I've installed pywin32-224.win-amd64-py3.7.exe from https://github.com/mhammond/pywin32/releases/...
0
votes
0answers
13 views

Find the value of a specific key in a nested dictionary

I have a nested dictionary customer_order = {order0 {'Orientation': what_orientation, 'Size': what_size, 'sizecost': size_cost, 'eyelets': how_many_eyelets, 'eyeletcost': eyelet_cost, 'material': ...
2
votes
1answer
15 views

Discord bot is not finding channel by name

I am making a Discord bot and when it boots up I am having it search through the guilds text-channels and checking for a specific channel name. If I print out the list of channels, it finds all of ...
0
votes
1answer
17 views

How delete irrelevant rows from dataframe?

Imagine that in column S1 an event, and in column RES its result. How can I leave in the data frame only the last result of each event? Source data frame: S1 RES DATE red 1 01.01.2019 red ...
0
votes
0answers
12 views

how to get column name based on value

A B C D a -0.023688 2.410179 1.450520 0.206053 b -0.251905 -2.213588 1.063327 1.266143 c 0.299368 -0.863838 0.408204 -1.048089 d -0.025747 -0.988387 0.094055 1.262731 ...
0
votes
0answers
8 views

Putting a CPU temperature monitor into my GUI PyQt5

So I wanted to make a sample GUI where it would show the CPU temperature (per core) and update every 5 seconds. How can I do this? I am using PyQt 5 and QT designer. Thanks, Salmaan
0
votes
1answer
7 views

How to get avatar url of the person who sent the message?

How do you get the avatar url of the person who sent the command from the context? @client.command() async def test(ctx): print("Username is = " + ctx.message.author) print(ctx.message.author ...
0
votes
1answer
22 views

Passes the first case but fails the other cases

Okay so I finished a code on hackerrank. It passes the test case but once I submit it fails the others. I have scanned through the code several times without a solution. Any thoughts on this? I have ...
0
votes
0answers
11 views

How to adequately plot image gradient orientation using matplotlib.pyplot.quiver?

I am having some issues getting a decent looking plot (beginning to question if it's possible) of the orientation of the image gradients for a given image. Below is a minimal example based off of ...
0
votes
0answers
10 views

Pipeline that cached the results

I use pandas to do feature extraction for machine learning. I hope to achieve the following: Consider I have five data processing steps done sequentially, and I execute it once, the results will be ...
0
votes
1answer
18 views

How can I have one keyword OR a different one in NewsAPI python?

I'm using Python 3.X, with NewsAPI.org's API. I want to be able to find news articles that have a keyword from a list of keywords. I tried putting commas in the keyword part of NewsAPI's url, but that ...
1
vote
0answers
16 views

How can I set the size of my Tkinter widgets in pixels?

Every time I have to design a GUI in Python, my go-to is always PyQt5 (Qt Designer 5) because it's, in my opinion, easier than Tkinter, but now I have an assignment and it's mandatory to use Tkinter. ...
0
votes
0answers
10 views

slurm: if the python module is modified will the running job be affected?

If I modify the Python module that is being used by a running job that is submitted by sbatch, will the job be affected?
2
votes
3answers
27 views

Find the maximum number in a list using lambda function, without max(),sort(),sorted() , and 'in' keyword in python3

And not import other modules except sys what I've tried, occurs an error: TypeError: 'function' object is not iterable A = [-1, 3, 7, 99, 0] print(map(A, lambda x, y: x if x >= y else y))
0
votes
0answers
7 views

Assign the output from %history of Ipython shell to a specified variable

Reference to Run Ipython as a shell, a variable can get the output from shell commands In [12]: lines = !ls -l | sed "s/$USER/me/g" In [13]: lines Out[13]: ['total 40', 'drwxr-xr-x 2 me me 4096 ...
0
votes
1answer
14 views

Python pip install problem with modules ( Win 10 ) [duplicate]

I've been using Windows 10 on my laptop for about 4 years.And I also had Python with several modules easily installed on it. However, a few days ago I had to reset Windows and delete everything. Now I ...
2
votes
2answers
31 views

How to extract keys with its values and add values to print the total in python dictionary?

Here I have menu of a restaurant and its price. I want to check orders and add prices and print total price for order. But I am unable to extract values of keys for specific orders. How to show orders ...
1
vote
1answer
11 views

How to slice a pandas.DatetimeIndex?

What is the best way to get dates between, say, '2019-01-08' and '2019-01-16', from the pandas.DatetimeIndex object dti as constructed below? Ideally, some concise syntax like dti['2019-01-08':'2019-...
0
votes
0answers
8 views

Kivy: AttributeError with property defined in kv file

Python: 3.6.8 Kivy: 1.9.0 PyCharm: 2019.2.3 I'm reading "Kivy – Interactive Applications and Games in Python Second Edition" while writing and testing the source code in the book. When I was ...
0
votes
0answers
10 views

Generating Labels at runtime using kivy

Hello I currently have a window in kivy that I am trying to generate labels at runtime with, Needing to do this in python since the text that is contained within each label is generated at runtime and ...
0
votes
1answer
26 views

Difference between two variable assignments in function scope modifying global vars [duplicate]

What's the difference between doing: m={} i='a' def change(): m['a'] = i i = 'b' Which raises an attribute error: >>> change() UnboundLocalError: local variable 'i' ...
0
votes
1answer
25 views

Calculate Word Frequency in Python Dict

I have a dictionary formatted like this: dict1 = { 'one': 'this list is the first one and may be unique', 'two':'this is the second list and also may be unique', 'three': 'this is the 4th ...
-1
votes
3answers
41 views

Method to multiply any input number to the next whole number

My goal is to take any rational number as input into a function and output the next whole number that is a multiple of the input number. Is there a method to determine the rational expression for any ...
0
votes
1answer
7 views

Why does PyODBC Thinks my SQL Only has 1 Param

Can someone help me understand why ODBC is only thinking I have 1 parameter in my sql? sql = """ IF OBJECT_ID('?', 'U') IS NOT NULL begin DROP TABLE ? end""" cursor.execute(sql, ...
0
votes
0answers
8 views

Why is my regex working fine on sublime text but not working while searching using re.findall even on using escape charaters [duplicate]

I am writing a code to remove all the duplicate characters to once if the characters exists more than twice, i.e in the list of words word_list = ["deep", "partyyyy", "groom", "dooom", "yeahhhhhhhh"]...
-1
votes
0answers
18 views

Pattern Design Program not working correctly

I have two codes that work together to draw patterns using import turtle. I don't know if the code works properly or if it is 100% correct because I get multiple errors that I don't know how to fix. I ...
-1
votes
1answer
16 views

Adding a value to a list thats named the same as another one with an extra letter or a sliced off letter

Title may be confusing, but what i'm trying to do is, Adding Something to a list, and that list, is named the same as that Somethings list, but with an extra letter sliced off. I could do this for ...
-2
votes
0answers
11 views

Passing an instance of an Object to a QDialog

I'm trying to build my first GUI in python using QtDesigner. I need the methods associated to the the buttons inside the QDialog (the main window of the GUI) to work on a Object Instance (let's call ...
0
votes
0answers
34 views

'Image' object has no attribute 'read'

I want to use the image stored in the dictionary, to convert it to gif. the photo in the dictionary is like this type. I think is a pillow image. But why it always says 'Image' object has no attribute ...
-1
votes
1answer
19 views

Is there a problem with how I am indenting this if loop? [duplicate]

I am learning python right now, and I'm working on making graphics. It was working for a while, making a window and displaying the correct graphics, but somehow I messed up the formatting and now it ...
0
votes
0answers
13 views

Error when importing the ssl module in Python3.7

When I run import ssl in Python 3.7.4, with the Anaconda Prompt, I get the error: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\<user>\...
0
votes
0answers
11 views

react-native not fetching content from externally visible flask server - “Network request failed” on development

I have a local flask server that has the config flask run --host:0.0.0.0 as specified in the docs. Instead of receiving a response from my flask server when i call it from react-native, I get this ...
0
votes
3answers
26 views

Calculate odd and even averages of whole numbers

I need to write a program to calculate the even and odd average of whole numbers input by the user. The user types “done” to complete. The output will show the average of the odd numbers, and the ...
-2
votes
0answers
15 views

Implementing bucketSort using a given function definition

I need to implement bucketsort in python3 using the following function definition: def bucketsort(A: list, size: int) -> list Where size is the number of buckets. I know how to write it normally, ...
0
votes
0answers
6 views

How i get the data of a event in python sockeio-client?

I am using this: @sio.on('changeTemp') def on_message(data): equip.data = 10 print(data) sio.emit('equipConnected', equip.SerializeToString()) How do I print or use ...
0
votes
0answers
12 views

how to get amp template in django

thaks for your time. i've beeing trying to work with AMP for front-end and django for the back although i've been having some issues with the tags. Ex(amp-carrousel): <amp-carousel class="cars" ...
0
votes
0answers
11 views

Most efficient way to express/specify and match/query/compare arbitrary date/time conditions against datetime object

In the config of a Python 3 program of mine, I need to be able to specify arbitrary date/time conditions, such as for example the following: Every Monday between 11:00 and 14:05 The 1st and 10th ...
1
vote
3answers
37 views

Generate Random Seed In Python

Is there a way to generate random seed? something like this: def random_seed(length) output example: 3273650411015667511766 or is there a way to do both nums and letters? output example: ...
0
votes
0answers
7 views

WTForms Label Position / Hiding Label

I've build a form using HTML / CSS with Bootstrap and I'm trying to integrate WTForms into it - everything was working fine and formatting perfectly until I started formatting the fields using wtf....
9
votes
1answer
38 views

How to access closed over variables given only the closure function?

In the following example: def speak(volume): def whisper(text): print(text.lower() + ('.' * volume)) def yell(text): print (text.upper() + ('!' * volume)) if volume > 1:...
-1
votes
2answers
20 views

In String Slicing str [:3] , in case the string is less than length 3, will this slicing return or not? [duplicate]

If I have a string of variable length and I want to return only first 3 characters of the string. str[:3] this works but I want to know if the string is of lesser length, suppose 2, "ab" or just "a",...
-1
votes
0answers
15 views

Icon launches Python script but doesn't save .txt

I created a simple program using tkinter. Whether I run it by clicking on piriquita.py or through terminal, the data log_piriquita.tx is created if it doesn't exist or it is appended if it already ...
0
votes
0answers
22 views

Build a dataframe from .pgn (string row)

I have a single .pgn (Portable Game Notation) of a large number of chess games. The games are contained in the file like this: [Event"FIDE World Cup 2017"] [Site "Tbilisi GEO"] [Date "2017.09.05"] [...
0
votes
0answers
15 views

Convolution autoencoder output

I try to to create a convolution autoencoder. In output I receive 5004 neurons, but on input I have 5000 neurons. Why is this happening? I've got: def create_deep_conv_ae(): input_signal = L....
0
votes
2answers
49 views

converting str to int

I have a text file and trying to process it. at the end I have to convert one of the variables from str to int. if I print the variable using this command: print(y_test.iloc[:,1]) I would get the ...
0
votes
0answers
20 views

Understanding map function [duplicate]

What would be the closest equivalent to the map function in python? For example: def my_map(func, arg_list): return [func(arg) for arg in arg_list] def my_squared_func(arg): return arg * arg ...
0
votes
0answers
16 views

whisker size of boxplot matplotlib

I was trying to plot a boxplot in matplotlib, then I realized the length of one of the whiskers is not right. I calculated the IRQ, q1 and q3 (16.0 , 62.0 and 78.0). I used this command: plt.boxplot(...
0
votes
2answers
31 views

Install request library with anaconda

I tried to use sudo pip install requests but the terminal keeps stating that: (base) OSX-MacBook-Pro:~ osx$ sudo pip install requests WARNING: The directory '/Users/osx/Library/Caches/pip/http' or ...
3
votes
3answers
37 views

How can I show the guessed letters of a word guesser in order? Python

I've been asked to create a word guesser in python which outputs to the user how many letters are in the word, for example python has 6, so it would output 6. Then the user has 5 guesses to guess what ...