Categories
Mastering Development

Creating a hierarchical dictionary with nested lists or dictionaries from 2 lists

I have 2 lists. The first has number denoting what part of the hierarchy that the value in the other list at the same index belongs. I am trying to get dynamic code that could theoretically go to any number of steps. The first 3 work correctly but when I had more steps to the […]

Categories
User Help Web Apps

Google sheets: How do I convert rows with 45 columns into 15 separate rows, each with 3 columns?

I am working with a google sheet that gets data from an email parser. Each time an email comes in, a single row is created, and fills in these columns: B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, […]

Categories
Mastering Development

Is there a method to convert a letter into it’s index in a tuple in python?

What I mean by the question is if i had: alphabet:["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"] and received an input of "a" I would get back an index of 1, or z to get back an index of 26, from the tuple’s index. I’m wondering if there is an easier way instead of using a dictionary. So like if I […]

Categories
Mastering Development

How does Python’s random.shuffle() alter the value of a list without returning anything and is this something any Python coder can do as well? [duplicate]

I just noticed I wasn’t getting a return from random.shuffle(). I realised this makes sense as you would logically want to work with the original list unless specified otherwise. >>> import string >>> import random >>> letters = list(string.ascii_lowercase) >>> print(letters) [‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, […]

Categories
User Help Web Apps

Creating Hyperlinks of Google Drive Items in Alphabetic Order

The original post that I got the google script editor code from was here: Get share link of multiple files in Google Drive to put in spreadsheet It works perfectly fine, but what I want to do is show the actual google drive link in the excel file (not the name of the file that […]

Categories
Mastering Development

Python Exception: Data must be 1-dimensional

I have a function findMaxEval which I invoke in a following way: eMax0,var0=findMaxEval(np.diag(eVal0),q,bWidth=.01) where np.diag(eVal0) is an ndarray of shape (1000,), q is a number (10). findMaxEval has the following definition: def findMaxEval(eVal,q,bWidth): out=minimize(lambda *x:errPDFs(*x),.5,args= (eVal,q,bWidth),bounds=((1E-5,1-1E-5),)) if out[‘success’]:var=out[‘x’][0] else:var=1 eMax=var*(1+(1./q)**.5)**2 return eMax,var This funtion tries to minimize errPDFs which is defined as follows: def errPDFs(var,eVal,q,bWidth,pts=1000): […]

Categories
Database Development

Split date range (timestamp) into equal parts by Month- SQL Server Synapse

Experts, Have a question regarding splitting a date range into equal parts by months including the time part example – fromdate – 06/29/2020 09:00:00 and todate – 06/29/2021 09:00:00 Want to split this date range into twelve equal parts like below 06/29/2020 09:00:00 – 06/30/2020 12:59:59 07/01/2020 00:00:00 – 07/31/2020 12:59:59 ……… ……. 06/01/2021 00:00:00 […]

Categories
Mastering Development

Unable to upload to Azure blob asynchronously with python

I’m trying to upload images to azure blob storage and before uploading I’m checking with head request to make sure that file doesn’t exists. Code runs well but stops after sometime. I tried to close file but it is not working. Below is my code from azure.identity.aio import ClientSecretCredential from azure.storage.blob.aio import BlobClient from azure.core.exceptions […]

Categories
Mastering Development

Randomly Assigning ID Tags to different Sections in R

I am having trouble randomly assigning ID Tags to a Section. I generated a random string of 347 made up three-letter ID Tags (i.e., sbn, hjk, cvl). I would like each individual ID Tag to be randomly assigned to a Section (i.e., w,v,g,b). There are a total of 47 Sections. After assigning the ID Tags […]

Categories
Mastering Development

How to plot different plots on same page in python?

I have plotted 10 plots but they are showing in different windows but I want to plot grid of separate plots of descent size on same page or within few pages. Code that might help to reproduce my condition is: matrix=np.random.randint(0,100,(50,10)) df=pd.DataFrame(matrix) df.columns=[‘a’,’b’,’c’,’d’,’e’,’f’,’g’,’h’,’i’,’j’] f=pd.DataFrame(np.random.randint(0,100,(50,1))) f.columns=[‘f’] for i in range(len(df.columns)): plt.scatter(df.iloc[:,i],f) plt.show() The desired output should […]