Consider the below dataframe: Assuming my index is unique, I’m looking to retrieve the unique values per index row, to an output like the one below. I wish to keep the empty rows. I have a working, albeit slow, solution, see below. The output number order is not relevant, as long all values are presente…
Packaging executable, shared library, and Python bindings not finding library
I have a project, cloudgen, that I would like to add bindings for Python so I can access some of the underlying functions. I have stubbed out the initial work on a branch. Because the main executable is built with cmake, I decided to use scikit-build to manage the build and use pybind11 to deal with the bindi…
loop through the list to get Maximum sum for a given range in python
I am a novice in python. I have a code where I loop through a list to capture maximum sum of numbers for given range k. It is working fine but I want it to make it shorter/optimal. ‘k’ may vary Ans: 1533 when k = 3 Ans: 1333 when k = 2 Answer You can start by adding up
How to make a for loop iterate a list and ask for input? PYTHON
I would like to make a program that asks how many bills of each type you got, to do this I wanted to use a for loop and a list. I did this little test: This only prints, not all three choices as I want: And when I give any input it gives me this error: ValueError: invalid literal for
How to combine dataframes based on index column name
Hello I am new to python and I have 2 dfs and a list of tickers and i would like to combine the 2 dfs based on a list of tickers. My second df had the tickers imported from an excel sheet and so the column names in the index are in a different order, I am not sure if
I am curious about the time complexity
I am curious about the complexity of:- a function that multiply input by 5 (n*5) a function that add 5 to the input (n+5) in (3) is the time complexity o(3**n)? Answer Strangely enough, O(func(n)) is just func(n). Why? The only real think your code can do is add 1. So whatever result it go, it got there by ca…
Expecting integer values in calculation, but getting
I am working on implementing an ID3 algorithm in python. In order to get past the first step I need to calculate the information gain per column. The comments are self-explanatory. The issue that I am trying to resolve is From the simple program shown below. The Test set for ID3.csv The Training set for ID3.c…
Django NoReverseMatch error – urls.py path appears to match
In a Django application I am building as a project for an online course, I am expecting a link in one template (entry.html) to direct to a path (“edit”) in urls.py with a variable in the url. This should initiate a function called edit in views.py and render the template edit.html. I am getting a …
count consecutive vowels in words
So, this is what I have so far to find vowels in each word in the text file. It doesn’t work, and I still need to be able to count how many consecutive vowels are in the words. If you can help, but make it to the level of simplicity I have done so far, that’d be great help. Lmk
Python regex that matches superscripted text
My question is very simple but I couldn’t figure it out by myself: how to I match superscripted text with regex in Python? I’d like to match patterns like [a-zA-Z0-9,[]] but only if it’s superscripted. regards Answer The main problem is that information about “superscript” and &#…