This question already has answers here: UnboundLocalError trying to use a variable (supposed to be global) that is (re)assigned (even after first use) (14 answers) Closed 5 months ago. I keep getting a syntax error when using += in python here is my code. I am also having troule with nonlocal. I am getting lo…
How to split a string in python based on separator with separator as a part of one of the chunks?
Looking for an elegant way to: Split a string based on a separator Instead of discarding separator, making it a part of the splitted chunks. For instance I do have date and time data like: Sometimes there’s D, sometimes not (however I always want it to be a part of first chunk), no trailing or leading z…
Creating a Tuple with a variable and Boolean Python
I’m supposed to add a variable and a boolean to a new Tuple – the actual assignment is below, with my code. I know tuples are immutable – this is the first time I’ve tried to make one. Additionally, I can’t find anything about inserting the variable and a boolean. Thanks in advan…
Python Uvicorn – obtain SSL certificate information
I have a gunicorn + uvicorn + fastApi stack. (Basically, I am using https://hub.docker.com/r/tiangolo/uvicorn-gunicorn-fastapi docker image). I’ve already implemented SSL based authentication by providing appropriate gunicorn configuration options: certfile, keyfile, ca_certs, cert_reqs. And it works fi…
In Keras, can I use an arbitrary algorithm as a loss function for a network?
I has been trying to understand this machine learning problem for many days now and it really confuses me, I need some help. I am trying to train a neural network whose input is an image, and which generates another image as output (it is not a very large image, it is 8×8 pixels). And I have an arbitrary…
Python: Date range into time series with corresponding values
My data set is much larger so I have simplified it. I want to convert the dataframe into a time-series. The bit I am stuck on: I have overlapping date ranges, where I have a smaller date range inside a larger one, as shown by row 0 and row 1, where row 1 and row 2 are inside the date
Click on interactive chart.js bar chart and get value for labels and groups in JS
I’m building an webapp where you choose airline companies and get a bar chart with scores in five categories(company, food, luggage, punctuality, staff). I want to get a value for company name and category, when a user clicks different parts of the chart. It’s to do further things in Python using …
Google kickstart 2020 round A wrong answer
link to problem : https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc7/00000000001d3f56 Problem There are N houses for sale. The i-th house costs Ai dollars to buy. You have a budget of B dollars to spend. What is the maximum number of houses you can buy? Input The first line of the inpu…
Python 2.7.12 on Ubuntu 20.04 in PyEnv
I have some legacy websites that run on Python 2.7.12 and have just updated my dev machine to Ubuntu 20.04. I am trying to get PyEnv to install Python 2.7.12, but it seems that this depends on libssl1.0-dev which has been dropped in Ubuntu 20.04. I get error: Following advice here I run: I get error: E: Packa…
Import Data from .csv file into mysql using python
I am trying to import data from two columns of a .csv file (time hh:mm, float). I created a database and a table in mysql. If I run the program with executemany(), result is the following: [’01:00′, ‘1’] ‘-1 was inserted.’ and after this I do get the error code: Not all par…