I have a df which as following Here what I want to do is combine those columns and we have two rules: If a column removes _C{0~9} or _C{0~9}{0~9} or _C{0~9}{0~9}{0~9} is equal to another column, these two columns can be combined. Let’s take number_C1_E1 number_C2_E2 number_C3_E1 as an example, here number_C1_E1 and number_C3_E1 can be combined because they are
Tag: python
How to debug crashing C++ library loaded in python project
I am attempting to figure out why calling a function in a dynamically loaded lib crashes python. I’m doing the following, I have a C++ function in a dynamic library file, which is loaded in python using ctypes. I then call the function from python: On MacOS, this works exactly as expected. Unfortunately on Windows 11, it does not. I’m
How can I predict the outputs using a prediction function? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 15 days ago. Improve this question I’ve created my own prediction function (R=C^3+Z^2+3) to predict my target variable. The problem is now I am dealing with a prediction function not an
Combine rows and average column if another column is minimum
I have a pandas dataframe: Basically, I would like to average the Power for each server but only if the difference is minimum. For example, if you look at the ‘PhysicalWindows1’ server, I have 3 rows, two have a diff of 100, and one has a diff of 500. Since I have two rows with a diff of 100, I
How to trigger a Javascript-generated HTML to show on the page with Python requests?
I’m using the requests module from Python to get a webpage that requires login to access. I know how to have requests enter the login details on a page, but I am having trouble accessing the form fields on this particular page because they are generated by Javascript after clicking a button. Here’s the website in question: https://pennmedialab.getconnect2.com/signin.aspx When first
Django execute previous action on refresh
I have tried to add a book in to the database using an HTML form. After the submission, the page redirect to a page where all the books are listed .Then whenever I refresh the page , the data is became duplicated. How do I resolve this problem? urls.py views.py Template file: Answer This is most common problem, the thing
AttributeError: ‘tuple’ object has no attribute ‘model’. How to fix this error?
I’m new to Django. Please help me to solve this error. I’m not getting any solution. I tried many stackoverflow solutions and GitHub solutions but I’m not getting where the error is coming from. urls.py models.py views.py serializers.py Exception log Here is the github link of the app – Django I tried many stackoverflow solutions but I am not understanding
How do I separate measurement value and unit into their respective columns if they appear together in DataFrame?
I have a DataFrame which contains measurements; e.g., weight, height, etc. However, sometimes the measurement column contains units together with values. Therefore, I would like to separate measurement values and units if they are together in DataFrame. Eg., In the below DataFrame, df, the height value and unit of the first entry are in respective columns. However, the value column
Substitute column values of a dataframe with the corresponding items in an array
I have a column in a dataframe which contains an array of numbers from 1 to 5 and I have an array containing five words. I would like to find the simplest, most compact and most elegant way in Python to “in place” replace the numbers in the column with the corresponding words. For example: I am certain that the
Sort the products based on the frequency of changes in customer demand
Imagine following dataframe is given. I have columns products, custome_demand_date (every week there is new customer demand for products per upcoming months) and months with quantity demand. How can I determine which product has experienced the most frequent changes in customer demand over the months, and sort the products in descending order of frequency of change? I have tried to