Questions tagged [python-3.x]
USE ONLY IF YOUR QUESTION IS VERSION-SPECIFIC. For questions about Python programming that are specific to version 3+ of the language. Use the more generic [python] tag on all Python questions. Use the [python-2.x] tags for Python 2 questions.
309,579
questions
-1votes
0answers
9views
To find min max average total number count and sum ouf the numbers when a word done is entered
total = 0 count = 0 average = 0 while True: number = input("Enter a Number: ") largest = number smallest = number try: if number == "done": ...
0votes
1answer
14views
How to create a new column based on conditions in the existing columns in a dataframe in python?
I have a dataframe like the below:
df:
PAN_NO COST_VALUE
AAA -0.001
BBB 2938080
CCC 49224091
DDD 100
EEE 50236272.32
I am trying ...
0votes
0answers
8views
Balena Cam deployment issue on Rpi 4 balenaOS
I am trying to simply deploy Balena Cam on RPI 4 running the BalenaOS.
Balena Cam Repo https://github.com/balenalabs/balena-cam.
I did both 1 click deployment and manual deployment.
Deployment is fine ...
0votes
1answer
28views
MASK csv columns using python3
I have below requirement to MASK 3 columns (MAILID,SSN,CCNO) with X (each char with X) using python3, I am trying with lambda function, but not getting exact output. any help on this?
ID NAME ...
0votes
1answer
52views
Creating "C Array" in Python
I am reading a book which is using ctypes to create C Array in python.
import ctypes
class Array:
def __init__(self, size):
array_data_type = ctypes.py_object * size
self....
0votes
0answers
5views
unable to register spark session on GeoSparkRegistrator.registerAll(spark)
I have been trying to register spark with GeoSpark. I have installed apache sedona 3.1.3 version in python 3.7. Spark session has created using
#Import required libraries
import os
import folium
...
0votes
0answers
8views
FASTAPI > Heroku Error: RuntimeError: Task <Task pending name='Task-6' coro=<RequestResponseCycle.run_asgi() running at /app/.heroku/
I was trying to Deploy my REST API built on FastAPI I'm using Motor for establishing connection with my MongoDB
I hosted the app on Heroku but now I'm getting the follow error:
2022-03-25T06:11:43....
0votes
0answers
4views
Running celery in projection after removing djcelery
Here i am running celery 5.1.2 on Ubuntu 16.04 with python 3.7 and Django 3.0
Previously in my project where python is 2.7 and Django 1.7 i used djcelery it worked fine and in my latest versions of ...
-1votes
2answers
24views
How to send 2 variables from a client to the server at the same time using sockets [Python]
Client.py
import socket
HOST = '127.0.0.1'
PORT = 65432
ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789.'
message = 'This message is encrypted using Caesar cipher'
def encryptstr(message,...
1vote
1answer
22views
if condition not meet, leave blank python code
how should we write the code that tell python to leave empty cell in dataframe when the condition is not meet?
I tries " " like excel but it does not work. I tried 'space' also not work ...
0votes
0answers
19views
How can i generate a new csv file every 5 minutes with my gps data?
I have a live data from my gps and i want to separate the data in different csv files every 5 minutes. For now, I can only export all the datas in one csv files.
here is my coding.
stream = Serial('...
0votes
0answers
6views
inputs needed on the tools for Code obfuscation for python 3.9.1
I am migrating my existing application from python2 to python3. In python2 I had used opcode shuffling to do the code obfuscation. When I try doing the same thing python is not getting compiled. has ...
0votes
0answers
6views
Is there anyway to call a python code from Mysql without using sys_exec()?
I need to call a python code from Mysql. And sys_exec() did not work.
I was wondering if there is any other way to call a python code from Mysql?
Thank you,
Saul
0votes
0answers
17views
How to efficiently make REST API call using aiohttp
I trying to write a script which will listen to some TCP message and do REST API to a server using the message. Each REST API call will take approximately 1 second. I want to make it efficient that it ...
0votes
0answers
22views
How to Register a user either by Email ID or by Mobile Number in Django? [closed]
I can register a user getting both email address and mobile number in my application. But what I really want is to register a user using either email or mobile number. So that if a user provides email ...
0votes
0answers
19views
How does ctypes.c_int differs from ctypes.py_object?
I understand that multiplying a ctype with an integer is declaring an array.
For example, ctypes.c_int * 4 is an array of 4 integers.
Then what is py_object?
Please help me understand how does ctypes....
0votes
0answers
13views
Make dataframe with user input and even if user directly press "Enter" without input consider no condition check for particulr column
I'm trying to make a data frame considering user input if user press "Enter" without entering anything. It should not check for condition in particular column
as well user can input one or ...
0votes
0answers
25views
Python unittest mocked method is called 0 times when it's being called at least once
I'm trying to assert the mock's methods are called once and expect it to pass. But somehow, the call count of mock_create_pool, mock_insert, and mock_close is 0 and not 1 or more. How can I test that ...
-1votes
2answers
34views
Python get first k elements from the list, which are present in another list
I have a list1:
[1, 2, 3, 4]
and another list2:
[4, 2, 10, 20, 3, 1]
I want to take 1st 3 elements of list2, which are present in list1:
Output-list
[4, 2, 3]
How to do this?...
0votes
2answers
44views
How to turn python to exe with only needed parts of library?
I made a simple script, turned it into an exe but the final output using auto py to exe with one directory mode was 170 mb, with one file mode it was 64 mb. Thats insane, anyway I can only copy the ...
0votes
0answers
28views
Packet sequence number wrong - got 1 expected 0
Getting the below error in MariaDb and its causing timeout issue : Debugged it with removing skip-name-resolve, granting privileges to user@localhost, and in pyton create_engine used pool_pre_ping = ...
0votes
1answer
16views
How to set QTable cell always in edit mode?
I have a table that need all table cell always in edit mode, I forgot how to set this behavior now, can someone give some tips?
The Demo
import os
import platform
from PyQt5.QtWidgets import *
from ...
0votes
1answer
13views
True or False: For an undirected graph, for every vertex, its edge with minimum weight is in a minimum spanning tree
I think this is true. With consideration to Prim's algorithm, the minimum edge of a vertex is either already in a tree, or will be selected eventually.
I also tried a lot of graph and they all seem ...
0votes
0answers
7views
Create proxy session with authentication and check websites ssl certificates
I have multiple websites that need a proxy for accessing them.
the proxy server that I'm using needs authentication first and then I can send requests to the websites.
Besides, I need to create a ...
0votes
1answer
26views
How do I correct my output so that it returns the specified categories with the corresponding tickers price sums inside the dictionary?
How do I correct my code so it categorizes my specified dictionaries ('Trash' and 'Tech').
Then add the sum of each ticker's prices of each category?
For example it would output: The string of the ...
0votes
0answers
15views
How to do integration testing for a dockized python files using pytest?
I have given a Machine Learning framework developed in python which is dockerized. I need to do integration testing of each python file inside the docker environment using pytest. How to proceed with ...
-2votes
0answers
23views
Print the stair shape like list using "for" loop in python [closed]
How do I write in python3 to print a list using for loop and loop counter to print a list like the image shown below:
Image Here
The list is follow:
berries = ['Blueberries','Raspberries','...
0votes
0answers
12views
Is there a way to simultaneously download multiple audio files in pytube?
I have made a youtube to mp3 app in python using pytube. I wanted to be able to download multiple songs at once, as in add them to a queue of some sort and all items in it would begin to download ...
0votes
0answers
4views
why am I getting ModuleNotFoundError: No module named 'yaml' while running exe file? [duplicate]
I generated .exe file using pyinstaller with .spec file , code executes correctly when I run it on conda environment but when I generate exe for this same environment and test it I get No module named ...
0votes
0answers
14views
[python]Double underscore keyword argument in class function [duplicate]
I have a strange problem.
I can't use double underscore keyword argument in class function.
Look this example:
class Test:
def fun(self, a, __b=None, **kwargs):
print(f"a: {a}|__b: {...
0votes
0answers
20views
Why does json.load give me an error even though I use the "with" "syntax"? [duplicate]
I have recently been interested in data and JSON files. I uploaded a file named "sarcasm.json" onto the computer and coded this out.
import json
with open("sarcasm.json", 'r') as ...
0votes
0answers
9views
Can I use folium in python with a different base map?
I want to use the interactive features of the folium module in python but for a custom map that I have created. Locations are to be mapped using basic x-y co-ordinates but not latitude and longitude.
...
0votes
0answers
10views
Switched from .render() to .to_html() when using dataframe.style and now getting TypeError: cannot pickle 'module' object
After creating a dataframe and styling it, I would originally use .render() to turn it into an html string. However, after switching it to .to_html() I am getting a type error.
After styling my ...
0votes
1answer
19views
can we use plt = matplotlib.pyplot instead of import matplotlib.plt as pyplot or is there an issue with this?
can we use plt = matplotlib.pyplot instead of import matplotlib.plt as pyplot or is there an issue with this ?
I was just curious whether it works exactly the same way or are there some issues with it....
0votes
1answer
27views
Trouble getting links from website scraper with BS4
This is the first time I'm making a website scraper and I'm relatively new to programming in general. So I'm trying to get the HREF links for all the subpages on this site:. But when I ran the code, ...
-2votes
1answer
27views
How to rotate a tuple?
I have a function with a tuple, example
def rotate_block(block: typing.Tuple[float, float]):
"""
Rotates a block
:param block: a block (width_block, ...
0votes
0answers
13views
psycopg2 connects from Windows, but not Ubuntu
My Postgres database only accepts requests from localhost. Requests from a remote computer rely on SSH tunnel.
with SSHTunnelForwarder(
('my.db.ip.address', 22),
ssh_username='...
1vote
3answers
67views
How to union words/find the maximum words in one list or string?
I have a string like,
str1 = "dogwood;dog;cat;cattree;"
I want to get the union results of this string,like
res = "dogwood;cattree"
how to solve this problem? If string is not ...
-1votes
0answers
26views
Can't Resolve "can only concatenate str (not "float") to str" - Student Learner [duplicate]
I have to make a very simple interface for the very first assignment of my Python class and I have no previous coding experience. Here is my code. I've added some fun embellishments as well. Help ...
0votes
1answer
17views
Reading data from a tab separated .txt and plotting it wrt index number and obtain ACF and PACF plots.. (Python)
To Obtain ACF and PACF plots.
I tried importing the data like this
df_icecream = pd.read_csv(data_path, sep='\t')
df = df_icecream.T
#print first 5 rows of the dataframe
for i in range(5):
...
0votes
0answers
15views
Remove library root on venv
I created a project in django
ear the venv folder
The words library root appear
why is it happening?
How do I remove / cancel it?
I want it to look like this without library root just venv
Screenshot ...
0votes
0answers
11views
QLineEdit setText
How may I able to fix this problem, I have a 2 frames, 1 frame will accepts a 5 inputs using QlineEdit and the other 1 is just a Empty frame, How to retrieve the given input in the QlineEdit? and ...
0votes
1answer
34views
How can you write a "for x in xs" with a where clause on one line?
I want to know if I can write the second line below somehow with one line. How I have it below is not working:
for page in paginator.paginate(Bucket=bucket, Prefix=prefix, Delimiter='/'):
keys = [...
0votes
1answer
16views
pip install --editable cause "running develop, error in 'egg_base' option: 'src' does not exist"
I tried to install my own python application via pip3 install --editable. But I got an error like "running develop, error in 'egg_base' option: 'src' does not exist".
The project has a src ...
0votes
0answers
6views
My tensorflow object detection model produced the average precision of zero for first class
I have trained the object detection model for three classes: id=1 (LR), id=2 (PM), id=3 (YR). Model produced AP(LR):0.002, PM:0.84,YR:1.00 and after that changed id=1 (YR), id=2(PM), id=3(YR). Model ...
0votes
0answers
14views
I was tring to generate sound waves, so I made a program, but it did not work
I was tring to generate sound waves, so I made a program, but it did not work, anyone has a solution to the problem?
my code:
import pygame as pg
import numpy as np
pg.init()
pg.mixer.init()
...
0votes
1answer
30views
Calculate total litres required to fill carpark using python3
I have to work out how many liters of concrete can fit into a park. Len park: 30.2m | wid of the park: 10m | liters per sq/m: 6.6. I have attempted this and am new to python and know how to calculate ...
0votes
0answers
27views
Pandas cross merge while combining a number of columns (Python)
I am working in python's pandas with 4 dataframes, each of which have a column of unique identifiers followed by multiple columns of shared attributes. I'd like to generate the cartesian product of ...
0votes
2answers
21views
Python Pandas adding a column where the value is across other rows
I would like to use multiple rows in the evaluation of a new column on a pandas dataframe. For a little background lets say that I have rows where data has been aggregated and I need to now how my ...
0votes
0answers
6views
How to activate nested Anaconda environment in VSCode
I have a python code A which upon execution activates conda virtual env B, runs code B and deactivates environment B.
I tried running code A in command line using Python 3.9.6 and also using Anaconda ...