I have a list of lists, where the first list is a ‘header’ list and the rest are data lists. Each of these ‘sub’ lists are the same size, as shown below: I want to merge all of these ‘sub’ lists into one dictionary, using that first ‘sub’ list as a header row th…
Tag: python
Location for Python version on macOS (using universal-installer for 3.10.5)
My very first post here, as new comer to MacOS and Python. Recently installed python 3.10.5 via macOS 64-bit universal2 installer .pkg file downloaded from python.org > Downloads > mac OS on MacOS 12.4 [M1/Apple Silicon]. In terminal, the command python3 shows the version as 3.10.5. But echo $PATH is gi…
Python program that tells you whether or not you need an umbrella when you leave the house [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 8 months ago. Improve this question The program should: Ask you if it is raining using input() If the input i…
Post files, but endpoint limits 50 posts per minute
Good afternoon, i’m completely new to coding and i need some help, i splitted a json file into ~2800 smaller json files and need to post to a certain endpoint, however the limit of the endpoint is ~50 files per minute. Currently i have made this is python : The file names are json1 -> json2800 Curren…
How to avoid memory error in Python while zipping list with large number of permutations from another list to get unique combinations?
I have the code below to generate all unique combinations between trucks and the permutations of tripares. The way I do it (below) gives me correct results. However it works only when len(tripares) < 10. When len(tripares) > 11 I get a memory error. Is there a way to avoid this memory error? Answer If y…
Transpose and Groupby pandas Columns
I’m looking to transpose pandas columns and apply a Groupby How can I achieve this expected output ? Answer Use DataFrame.stack for reshape with remove missing values and count values by Series.value_counts, last Series.sort_index with Series.rename_axis and Series.reset_index for 2 columns DataFrame: E…
Generate Excel files for each of element in a column using Python
I want to generate Excel files for each of element in a column : I will describe what I want with pictures : I have an excel file like this: I want for each element of the column “FRUIT”, to be on a different excel file like this : excel-BANANA.xlsx : excel-CHERRY.xlsx : excel-APPLE.xlsx : Is it p…
How to override output filepath and write it along with output files at a desired directory through argparse
I have the following example code and I use argparse to call and execute it. Below is the main.py script where I call the above code via argparse Since I’m working on a python pipeline, I would like to override the output filepath and give it via CLI, i.e., as an arseparse argument. As I’ve said i…
Deleting the useless output files using Python
After I execute a python script from a particular directory, I get many output files but apart from 5-6 files I want to delete the rest from that directory. What I have done is, I have taken those 5-6 useful files inside a list and deleted all the other files which are not there in that list. Below is my
How to create a url for two apps that have index function in django?
I am a newbie in Django. In one django project, I have two apps say college app and company app. In the college app. college/urls.py Company/urls.py How do I create a url of both these in the header.html ? I tried these but its not working. Answer There is a easier way to about this conflict just by using dif…