I currently have two dataFrames that look like this: Df4: I am trying to add a new column to Df3, which is the sum of all Sales (SalesAmt) where the invoicing date (InvoiceDt) is prior to the date column in Df3. I get the following error in this case: Any idea how to fix this? Or a more efficient way
Tag: python
Verify if elements of pandas columns have been shuffled
I have the following df: The above df represents the lines in a csv file where the del_el is an add_el on another line. I want to add a column action in which the value would be “replace” if for the same (name, id), the del_el is equal to the add_el column on another line_number. Desired output Sa…
Extracting first-layer weights from a multi-layer Keras NN and transferring them to a single layer NN
I trained a 3-hidden layer NN (3-HL) using Keras (with good results, and I wanted to extract the weights from its first layer (inputs to its first-hidden layer) and use them in a single-hidden layer NN (inputs to its single hidden layer), to train. The 3-HL model summary along with its extracted (hopefully fi…
Unable to get data collector to display values (Keeps displaying None value)
Hello I am currently using python telegram bot to create my bot, currently I am unable to use my data collector (which also functions to calculate my calories) to display the value I want) The issue is that it keeps returning a None value, does anybody know the solution why ? I understand my means of doing th…
type hints in a Python Google Cloud Function?
In a Python Google Cloud Function with a lot of sub-functions in the “main.py”, I added type hints (= return value annotation as part of function annotation) in pep8 style like this: Union is taken from here, it is needed if there is more than one type hint. The function cannot get deployed, there…
python for loop with if statement to divide numbers
if statement and for loop I am stuck with the following code, I have a column in which I want to divide by 2 if the number is above 10 and run this for all the rows. I have tried this code but it gives the error of the series is ambiguous: I suppose that I need a for loop
My code is freezing and using to much CPU power. (Python)
I am attempting to make a sort of AI like script which will figure out your phrase. It is still a work in progress and is not yet complete. Each guess should print the following info: The text produced: ……… The string generated by the script. The length of the text: … The length of the…
Extend the list with fixed values
I have the following list: I need to populate this list with the first value (i.e. 5) so that the length of this list becomes equal to 10. Expected result: I can do it in for loop: But is there any shorter way to do it? Answer Also consider Explanation: a[0] grabs the first element (10-len(a)) is the number o…
Python – Selenium – Scraping through multiple websites
I am trying to build a webscraper with python / selenium that scrapes data from multiple websites and stores the data in an Excel sheet. The sites I want to scrape are the following: From all sites I want to scrape the “Omsättning”, “Volym” and “VWAP” values and store them …
Function returns only first element of the list
I am trying to get every element from python list returned as a string, but it returns only the first element of the list, not continuing the loop. Main Code (prishot.py) Test code to run the above (test.py) After running the test.py it gives me only the first sentence in the list s in prishot.py: Screenshot …