Questions tagged [python]

0 votes
2 replies
How to access psycopg2 error wrapped in sqlalchemy error
I'm uploading a pandas data frame to a table in Postgres using SQLalchemy and psycopg2. How do I access the psycopg2 error that is within the SQL...
1 votes
0 replies
TypeError: 'module' object is not callable Flask JWT
I'm working on a Flask server where we have a route to validate a user's JWT token using the library flask-jwt-extended. This is what our route l...
asked 2 months ago
-1 votes
1 replies
Trying to ljust, center, and rjust output of stopwatch
I have a stopwatch program that is fully functional. All I am trying to do is format the output to be aligned. This was a section of the code b...
asked 2 months ago
-1 votes
5 replies
i+ =1 generating a Syntax error in for loop
eg. name = 'python' length = len(name) i = 0 for n in range(-1,(-length-1), -1): print( name[i], '\t', name[n]) i+ = 1 I remove the i+...
asked 2 months ago
-1 votes
2 replies
My program works but is very slow, it also slows down as it runs
I am pulling data from the Microsoft Academic Knowledge API and then using the json responses as dictionaries to extract the information I need....
asked 2 months ago
1 votes
1 replies
How to extract data from salesforce ordereddict hierarchy using Python & Pandas
Summary In short, I need to extract data from a pandas series containing individual OrderedDicts. So far progress has been good but I have now h...
0 votes
0 replies
How to inject different environment variable in dev, test, prod in Python
I used to work with Flask which offers an easy way to configure the application running in different modes. (dev, test, prod, ...) class BaseCon...
asked 2 months ago
0 votes
0 replies
Migrating pmp-check-aws-rds from boto2 to boto3
I'm looking to use pmp-check-aws-rds to monitor my RDS instances using Nagios. The plugin is currently using Python2.7 and boto library. I was ab...
asked 2 months ago
1 votes
2 replies
How is it possible to extract sub-strings using keywords and index?
I'm trying to get certain sub-string following a keyword from a data string. These colleceted sub-strings are then joined together. Is there a...
asked 2 months ago
0 votes
1 replies
Parser BS4 write to file
I'm study python and have a task. I have to write the scraping results to file, but there are some errors. Each string in the result file as "No...
asked 2 months ago
0 votes
0 replies
Low level API in tensorflow 2.0
I am very confused about the API in Tensorflow 2.0. How can I create a layer using the low-level API in Tensorflow 2.0? Using the high level API...
asked 2 months ago
1 votes
1 replies
How to generate a 3D grid of vectors ? (each position in the 3D grid is a vector)
I want to generate a four dimensional array with dimensions (dim,N,N,N). The first component ndim =3 and N corresponds to the grid length. How ca...
asked 2 months ago
0 votes
1 replies
Tensorflow: How to use Tensorflow's Dataset API to use TIFF images?
I'm currently using Tensorflow's Dataset API to load and preprocess images for training and testing. Here's a snipped of the code I'm using to do...
asked 2 months ago
-4 votes
1 replies
Is there a way to make randint() less pseudo and more random? [closed]
I'm working on a lottery simulator and I'm not quiet happy with the draws generated by randint. Are there any tricks to make it more random?...
asked 2 months ago
-1 votes
0 replies
How to Mock django chained queries using python unittest
func_to_test.py from models import MyModel def myFunc(): #Query 1 queryset_exists = MyModel.objects.filter(id=0).exists()) #Query 2 que...
asked 2 months ago
0 votes
1 replies
Slope of a regression line using numpy/pandas
I'm trying to write a piece of code that given two lists of numbers, finds the beta coefficient. This can be done by finding the slope of the lin...
asked 2 months ago
-1 votes
2 replies
inserting data into a table using pyodbc
im trying to insert data using python (pyodbc) into my database but i keep getting errors like missing comma and others i tried to use the varia...
asked 2 months ago
0 votes
1 replies
Create NonUniformImage based on Numpy 2d array with custom cell width and height
I'm trying to make a "heatmap" with Matplotlib of a 2d Numpy Array and found the NonUniformImage option here. Below is a simple single version. U...
asked 2 months ago
1 votes
2 replies
Can anyone help me with this PyCharm and Import Modular errors?
So I am trying to run this: import pygame from pygame.locals import * from OpenGL.GL import * from OpenGL.GLU import * But an error pos up and...
asked 2 months ago
0 votes
0 replies
Querying Access database through pyodbc sometimes works fine, but sometimes gives connection error
I am trying to execute SQL query in a locally stored Access database through pyodbc. In the code below, printing the table names works fine, so...
asked 2 months ago
-3 votes
2 replies
Python string to dictionary
Problem appending new records to variable/list (dictionary). I have created a program (adressbook) and imported a .csv file (headers are, name,...
asked 2 months ago
0 votes
0 replies
Mapping data to custom hoverData
Might be a bug... I can't correctly map my data to display as a tooltip when making a facet grid using Plotly's figure_factory. import plotly.of...
asked 2 months ago
1 votes
2 replies
Lookup if Dictionary key contains items in Python
If I have the following dictionary and list, is there a way that I can looking is the items in the list are contained within the keys of the dict...
asked 2 months ago
0 votes
5 replies
Convert integer to float
I am trying to write a function that converts integers to floats, and leave booleans and strings as they are. I have defined the following func...
asked 2 months ago
-5 votes
0 replies
Sun tracking with Raspberry LDR & stepper motors [closed]
i am building a solar tracker using raspberry Pi dual axis , 4 LDRs , ADS1115 and two stepper motors , is there any code i can use ? -5 P...
asked 2 months ago