Questions tagged [python]

Python is a dynamically typed, multi-purpose programming language. It is designed to be quick to learn, understand, and use, and enforces a clean and uniform syntax. Please note that Python 2 is officially out of support as of 2020-01-01. For version-specific Python questions, add the [python-2.7] or [python-3.x] tag. When using a Python variant (e.g. Jython, PyPy) or library (e.g. Pandas, NumPy), please include it in the tags.

python
Filter by
Sorted by
Tagged with
-2 votes
4 answers
66 views

* in print statement of python [duplicate]

I have this code to segregate odd and even numbers . Can't understand why is there a star mark (*) when printing lists of odd and even in the last : print(*even) print(*odd) what does the star imply , ...
Kunal Malviya's user avatar
0 votes
2 answers
99 views

How to add space in python's search/find string? [duplicate]

I have been running a pywikibot on Marathi wikipedia since almost a month now. The only task of this bot is find and replace. You can find overall details of pywikibot at: pywikibot. You can find the ...
usernamekiran's user avatar
0 votes
1 answer
886 views

How to plot comparison in Streamlit dynamically with multiselect?

I created a comparison app with streamlit and I want to compare it dynamically. Here's my code that i write import streamlit as st import matplotlib.pyplot as plt import pandas as pd sampel_data={'...
PostJavanese's user avatar
0 votes
1 answer
789 views

How do I specify language of tweet when using tweepy?

I'm trying to get tweets only in English. But when I specify lang, the resulting data frame is empty. When I remove it, I get up to 1000 tweets. number_of_tweets = 1000 tweets = [] time = [] for i in ...
anupam's user avatar
  • 3
0 votes
1 answer
73 views

for every dict in list of dict sort values by key

I have a large dataset stored in a dictionary, it consists of movies with keys like: titles, year, genre... I have them bucketized by genre as follows: [ {'Action': [ {'title': 'They Live', '...
Joan's user avatar
  • 31
0 votes
1 answer
88 views

Python - Webscraping - Select item in Dropdown

***> I'm trying to select an item in the dropdown and I'm not getting the > dropdown, it stops at the part and doesn't select the item I want - > Decarbonization Credit or "CBIO - ...
user avatar
1 vote
1 answer
1k views

Different price between yf.download and yf.Ticker

I am extracting the opening price of a stock, say "AAPL"(Apple Inc) using yfinance. I come across something very interesting, yet confusing details. I have used two methods to obtain the ...
user avatar
0 votes
1 answer
47 views

Grabbing links inside the td

The script below is working but I wanted to add the href link of the item to produce a better data output. Any help will do. Thank you. import requests from bs4 import BeautifulSoup headers = {"...
rbutrnz's user avatar
  • 383
2 votes
0 answers
1k views

Discord components (buttons), interaction don't work

im here to ask for some help concerning my discord bot in python, so i imported the discord_component and started making a command with button, i managed to successfully add buttons to a embed message,...
Skks's user avatar
  • 31
0 votes
1 answer
165 views

How to index a numpy list of lists with a list of lists of boolean values?

Preface I am currently using sklearn's Nearest Neighbors (NN) algorithm, and the output of a fitted model's method radius_neighbors returns an list of lists of radii representing the distance from ...
Edward's user avatar
  • 1
0 votes
2 answers
632 views

Create a variable that contains an image source from a kv to py in Kivy

I'm trying to get the image source and put in a variable from my kv to py. I created a function where my button change the image when pressing and releasing it. Well, this variable has to contains the ...
C0D3R's user avatar
  • 1
0 votes
1 answer
38 views

A question on interpreting function and lambda function in Python

I am having a hard time with a practice problem involving function and lambda using Python. I wonder if you could help me explain how this function works: The problem is: What is the expected output ...
brokenpc's user avatar
0 votes
0 answers
2k views

How to loop through folders in Azure Blob Containers

I have the following code which is written in Visual Studio Code. Now I want to run this in Azure Databricks. I have uploaded the entire folder to my Azure Blob Storage. I have named my container ...
user86907's user avatar
  • 837
1 vote
0 answers
2k views

TypeError: Need a valid target to patch

I have a directory structure like this: Business_Logic excel_format_error_checks.py tests test_excel_format_error_checks.py In my test_excel_format_error_checks.py, I am getting an error ...
meg hidey's user avatar
  • 272
1 vote
0 answers
19 views

Hiding console using --noconsole command but encountering error

I made and exe file using pyinstaller and when I m trying to hide the console using --noconsole or -w then this command runs perfectly pyinstaller --onefile --noconsole main.py But after running the ....
Krit Raj's user avatar
0 votes
1 answer
143 views

Is it possible to make a squircle button with Tkinter?

Is there any way to create a squircle button with tkinter? A squircle is a square with rounded corners. I was just curious if I can make a squircle button with tkinter..
Sanchez's user avatar
  • 55
0 votes
1 answer
171 views

Weird python syntax errors

So I have some code that gives three syntax errors but IT RUNS FINE, it almost like the syntax error are cosmetic or something. Its in a very large project that used googles cloud vision API, I might ...
CrimsonOcean75's user avatar
0 votes
2 answers
57 views

Python Hangman problem with function for printing "_ a _ _ e _"

I am programming a small hangman game and I have kinda no Idea how I should resume my program. I have the part of the program which is giving me a list of the letters which are guessed correctly. My ...
Ben Philipp Siemens's user avatar
0 votes
3 answers
105 views

How can i change this query to ORM?

Hi i have two models like this, class Sample(models.Model): name = models.CharField(max_length=256) ## processid = models.IntegerField(default=0) # class Process(models.Model): sample =...
Shale's user avatar
  • 378
0 votes
3 answers
89 views

How to merge two dataframes that have increasing number based column headings?

I have two data frames at the moment that look a bit like this but a lot larger. Dataframe 1: Q1 Q2 Q3 Q4 Q5 Q6 a b c d e f Dataframe 2: Q1 Q2 Q3 Q4 a b d f So,dataframe 2 is the same as ...
userj's user avatar
  • 158
1 vote
1 answer
757 views

Why does `python setup.py sdist` copy the entire directory into the dist file?

I am perplexed why this setup.py file # -*- coding: utf-8 -*- from setuptools import setup, find_packages with open('README.rst', 'r', encoding='utf-8') as file: readme = file.read() setup( ...
Freiburgermsu's user avatar
1 vote
0 answers
74 views

Microcontroller serial stops working when mu serial is closed

I am trying to control some NeoPixel lights, and because the Raspberry Pi can only control one light at any given time, I decided I would just get a microcontroller to do it, specifically the Adafruit ...
Lazuli's user avatar
  • 31
0 votes
1 answer
205 views

Highlight text in Python Idle

So I'm revising my code and I'm wishing I could highlight just the part where I made a mistake so it would be easy to spot the mistake if I come back to it and learn from it.... #Don't Need True When ...
Minju's user avatar
  • 3
0 votes
1 answer
224 views

In Python, why is my deepCopy still having its values changed?

I have made a class in python and I am trying to create a deepCopy of it, however the 'deepCopy' still has its values changed when I modify the original. class boardState(): def __init__(self, ...
Koby's user avatar
  • 3
0 votes
0 answers
64 views

Yet another (Probably SUPER IMPLE) Issue Python with Pillow for Image Generation

Once again I am trying to learn from mistakes and probably looking WAY to deep into this issue... I've been building an NFT Project and have My Data list in a .CSV file (This file explains how to use ...
Justin's user avatar
  • 1
0 votes
0 answers
575 views

How to check if an object is already exist in list of object in Python?

I have a list of objects (ls) that contains some objects of the same class: >>print(f"list: {ls}, {type(ls}") list: [<__main__.Puzzle object at 0x000001C061BBBB20>, <__main__....
sempraEdic's user avatar
0 votes
2 answers
669 views

SciPy error: RuntimeWarning: overflow encountered in _beta_ppf

My SciPy version is 1.7.3 and I'm running on an Apple M1 chip (not sure if it's relevant). My Python version is 3.9.11, installed via Annaconda. I get the error message /opt/anaconda3/lib/python3.9/...
ramund's user avatar
  • 185
0 votes
0 answers
133 views

How do I import python scripts into python scripts?

I'm trying to import a python script to my other python script because I don't want all the functions at the top of my main script. This may sound stupid because I'm still learning python as well as ...
Noah Robb's user avatar
1 vote
2 answers
422 views

How to use Requests.Get to produce a list of status codes for a large number of sites

I'm a novice python programmer and I'm trying to use the requests library to find http status codes for a large list of urls, put those status codes into their own array, then add the status code ...
sleepy's user avatar
  • 13
1 vote
2 answers
263 views

Using following-sibling to access divs within following-sibling

I'm trying to get information from this URL: https://www.bandsintown.com/e/1024477910-hot-8-brass-band-at-the-howlin'-wolf?came_from=253&utm_medium=web&utm_source=city_page&utm_campaign=...
DiamondJoe12's user avatar
  • 1,921
0 votes
1 answer
261 views

Discord.py I want a role to be added when someone has a Specific thing in there status

my name is Mali my friend Env is trying to make something where it can give people roles if they have his server invite in their bio this is what he has so far: async def status_check(guild): ...
Mali's user avatar
  • 1
-1 votes
1 answer
1k views

Python program that takes in a Name and 10 Scores and Returns the Name and 6 highest Scores

name = input("Enter name: ") scores = input("Enter 10 test scores separated by commas: ") data = zip (name, scores) for (student, score) in zip(names, scores): pass print(name)...
ScottV's user avatar
  • 17
-2 votes
1 answer
4k views

Pulling Zabbix Data into csv file

Can't seem to find the correct syntax to get the request I need. At this point I am able to connect to my Zabbix server via an API. I'm able to see all the data that I need which is confirmed by a ...
Lachlan's user avatar
  • 17
0 votes
2 answers
214 views

How to output the correct statement in a loop using python

I am currently working on some python (version 3.10.4) code on PyCharm (Community Edition 2021.3.3) using the python-docx library (version 0.8.1.1), that allows to determine if text (in a Word ...
user avatar
1 vote
1 answer
173 views

I am trying to make a command where i can enable/disable my Welcome Event on discord.py

So ive successfuly created a welcome message for users when they join the server which functions properly but, I want to make a command which allows me to turn the Welcome event off or on How can I do ...
vloyne's user avatar
  • 9
-3 votes
3 answers
67 views

How to add new values to a value of dictionary in python

I want to add a value to a dictionary as the follow: dic = {'key1': {1: 1}, 'key2': {2: 5, 1: 1}, 'key3': {2: 2, 1: 2}, } Want to add a value for "key1" => {3:4, 1:5} ...
Jojo's user avatar
  • 952
0 votes
0 answers
237 views

How to layer widgets in a qgridlayout cell? Wrong widget is on top

I have a Python PyQt5 interface with a QSvgWidget holding an SVG image and 2 text labels that I want to sit on top of it (I'm using a QGridLayout). The SVG and label are dynamic; that is to say, they ...
j.c.'s user avatar
  • 1
1 vote
1 answer
121 views

My string of if elif and else statements aren't working and I have no clue why

I am trying to make it so the characters in the word are each run through a program that changes it to a different character if it's a vowel. This is the code. word = input(";") for ch ...
Peanut Walrus's user avatar
1 vote
1 answer
170 views

Cross-checking dataframes in Python

I am working on a Pandas issue. Currently in df1: start Stop NYPenn WUnion GCTerm 30thSt TUStat LAUnio JaStat MillSt ChiUnS MonCen OGTran SouthS Currently in df2 (Prime): Train_Code City ...
PickleRick's user avatar
0 votes
3 answers
121 views

How am I able to return value from Python function without passing in parameter?

Why am I able to call to and return variable (HTTP request) properties from this function without passing a parameter first? How does the f in f"abc123" work? import requests def oauth(r): ...
otonomi's user avatar
0 votes
2 answers
655 views

TypeError: on_ready() missing 2 required positional arguments: 'ctx' and 'message'

when trying to run my discord bot i get an error in my code for this command, it says that i do not have 'ctx' and 'message' even though its in line 2 of the code @bot.event async def on_ready(ctx, ...
user avatar
0 votes
1 answer
350 views

django.setup() in single file in 'apps' folder, got 'apps' is not a package

Solved by sys.path.insert(0, project_root) , I don't know the reason, if use sys.path.append will get this error. Tried to create projects in apps folder, got error -- 'apps' is not a package. init ...
wgf4242's user avatar
  • 799
0 votes
1 answer
80 views

Determining touch execution hierarchy when inheriting from multiple touch classes in Kivy

I'm trying to combine functionality from KivyMD MDCardSwipe and kivy_garden drag_n_drop. MDCardSwipe allows you to swipe a card to the side to reveal an underlying widget -- in my case with a trash ...
awhitin2's user avatar
0 votes
0 answers
319 views

How to convert argument passed to string with TextBlob?

I'm trying to learn how to scrape tweets using python. I'm trying to use the following code, but I keep getting the error. I'm not sure how to rectify it. def fetch_tweets(query, count = 50): api =...
anupam's user avatar
  • 3
0 votes
2 answers
855 views

Pandas Groupby Syntax explanation

I am confused why A Pandas Groupby function can be written both of the ways below and yield the same result. The specific code is not really the question, both give the same result. I would like ...
Ty Swenson's user avatar
0 votes
1 answer
1k views

Pyspark: Incremental load, How to overwrite/update Hive table where data is being read

I'm currently writing a script for a daily incremental ETL. I used a initial load script to load base data to a hive table. Thereafter, I created a daily incremental script and reads from the same ...
GreenBlazerrr21's user avatar
0 votes
2 answers
45 views

My guessing game not functioning correctly

It's not selecting the level of difficulty. Did I forget something? For example, I want it to select 3 for hard, which then leads the game to select from 1 to 1000 with 5 tries. and if the user ...
vick's user avatar
  • 11
2 votes
0 answers
615 views

Use Proxy with Authorization in Firefox with Selenium in Python

How to provide Username and Password to a proxy server in Firefox with selenium in python? I tried the code below but the IP address doesn't change. I check the proxy setting in Firefox, it shows that ...
zurich_ruby's user avatar
-2 votes
1 answer
155 views

How to access a dict from a PY file in Jinja for Flask Website

Im creating a site on flask, using jinja i want to access a dict from my dict.py file to display a table on my template but I am given a 'coin_dict' is undefined error on when i render. Any help? ...
Nick_Lopez43's user avatar
0 votes
0 answers
47 views

URL is being changed from webpage but no 301 (redirect) status code. How is this possible and how do I capture the new URL

so in the past few days I've been wondering how this works. Basically Twitter added a new profile feature where you can put /nft at the end of a profile URL and it would show you if that user owns an ...
tld's user avatar
  • 39