Category "python"

How to create a dual-stack (v4+v6) python UDP server?

By searching for 'python dual-stack', I found https://bugs.python.org/issue25667 where someone mentions that this was already resolved in https://bugs.python.or

Fill in uneven sized lists in Python

I have a 2D-List contains unequal size lengths, like this: lst = [[1,2,3],[-1,2,4],[0,2],[2,-3,6]] I use this code to insert a 0 if element size less 3: newlis

python stream file : no idea why this doesnt work ( but i have same stream id every time )

PS : (due to my country's teaching program, I need to write python code like this ) Hello, I have no idea why this doesn't work: from pickle import load,dump

Making multiple "any" more efficient

I am using any to see if a string in a longer string (description) matches with any strings across several lists. I have the code working, but I feel like it's

ValueError: Cannot feed value of shape (1, 256, 256) for Tensor 'input_x:0', which has shape '(?, 256, 256, 3)'

Code: from deeplab_v3 import Deeplab_v3 ### from data_utils import DataSet ########## import cv2 import os # import tensorflow as tf

How to import data with dates as index from excel with pandas

I am importing the data with this command df = pd.read_excel('C:/Users/Me/Data.xlsx', sheet_name='Prices') and this is the result: The date is a common column

Reverse sort order for part of a key

I need to sort a list of objects. Currently I am doing it like this: mylist = [aobject, bobject, cobject] mylist.sort(key=mykey) def mykey(sortelem): attrib

How do I create a while-loop in python with showing a random object from my list? [duplicate]

So I have the following task: First generate a list with strings of fictitious names for image files (e.g.my_list['image1.png','image2.png','i

Unnest json dict to rows in pandas

I have the following dataset from a json file: mydf = pd.DataFrame({ 'load': { 0: {'id': '100','name': 'Joe'}, 1: {'id': '101','name': 'Ann'}, 2: {'id': '1

How to locate print output? or convert it into jpeg?

I'm trying to show more than one dataframe with using tkinter. There are 2 options for me, showing dataframe directly by using print() and saving dataframe as j

How do I form this POST request with Python to upgrade Axis firmware?

I am attempting to upgrade the firmware on an Axis camera, and according to their documentation here, requires sending the request below. I am using the Python

close chrome browser via script

I want to make a program that when started quits Chrome (if it's open) and the link won't work, it just asks me to look for an app in the Microsoft store, pleas

Separating files based on file extension?

I want to separate the files in my models based on extension type. Right now I am able to print all the files but now I want to separate them based on extension

How to control the color of a specific column in a bar plot depending on it's xtick label?

I have a number of plots that show transcribed text from a speech to text engine in which I want to show the bars where the S2T engine transcribed correctly. I

Run shell script which is on hdfs location from a pyspark script

I have a requirement where i have to run call a shell script which is on hdfs location and run the shell script from a pyspark script. My code is something like

how to insert data from list into excel in python

how to insert data from list into excel in python for example i exported this data from log file : data= ["101","am1","123450","2015-01-01 11:19:00","test1 test

Can't get the walrus operator to work (Python double list comprehension)

This list comprehension does not work: buy_prices = [(buylow := round(0.997 + ii/10000.0, 5), max(jj, buylow)) for jj in [buylow, 0.9982] for ii in range(21)]

How to fix 'no module named requests'

I have requests module installed but it shows an error when running .py file from cmd prompt. There are no errors when running the file from vscode.

How to fix the error where the target batch size does not match when I use CrossEntropyLoss function?

I am working on a trainning task with CNN. When I created the loss function with CrossEntropyLoss and trained the dataset, the error reminded me that the batch

About removing an item from a list with a for loop

Let's say we try to remove all elements of a list with the following code: a = [1, 2, 3, 4] for i in a: a.remove(i) Of course this is not "permitted" and w