I am getting this error when i use many to many field help me plsssssss views.py I’ve been stuck here for 3 days now. At first I used it as a CharField so I could add it, but when I added another ID it couldn’t add it. It says there is a problem in this part ship_id_max = shipping.objects.aggregat…
Tag: python
issue with setting concatenated string variables in __init__ using variables set within __init__ as part of the concatenated string [closed]
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers. Closed 3 m…
TypeError: unsupported operand type(s) for /: ‘list’ and ‘int’ solution is an array
I solved an equation, the answer is an array. I am trying to use the answer for a new equation. I wrote a sample code to explain my problem! Answer I see you want to “use the answer for a new equation”. The previous equation solution is a, a list with 1 element [1] then you can use a[0] in
Insert $ in front of numbers in column using Pandas
I wish to add dollar symbol in front of all the values in my column. Data Desired Doing I believe I have to map this, not 100% sure. Any suggestion is appreciated. Answer You can also try
Derivative using Numpy or Other Library for lambda sin function
So i have this newton optimation problem where i must found the value f'(x) and f”(x) where x = 2.5 and the f = 2 * sin(x) – ((x)**2/10) for calculating, but i tried using sympy and np.diff for the First and Second Derivative but no clue, cause it keep getting error so i go back using manual deriv…
Is it possible access a list stored in a dataframe in a vectorized manner?
Considering a dataframe like so: I want to create a new column ‘extracted_value’ which would be the value contained in the list at ‘indexes’ index (list = [0, 1, 2], indexes = 0 -> 0, indexes = 1 -> 1, and so on) Doing it with iterrows() is extremely slow as I work with dataframe…
How to prevent np.where from turning 0 into ‘0’?
I want to create an array with np.where that has strings and 0s in it. So usually its dtype would be ‘object’. Minimal example: As a result I get I would like those ‘0’s to be 0s. Since np.where has no argument for dtype, I don’t know how to do this except by replacing them after…
How to perform split/merge/melt with Python and polars?
I have a data transformation problem where the original data consists of “blocks” of three rows of data, where the first row denotes a ‘parent’ and the two others are related children. A minimum working example looks like this: In reality, there are up to 15 Providers (so up to 30 colu…
groupby in pandas with custom function over a subset of rows in each group
I have a pandas DataFrame of the following format: Input: where (version, branch) is a MultiIndex. PROBLEM DESCRIPTION: I want to groupby version and set the values in the column X with branch overall to the sum of the values in the column X for the remaining branches (having the same version), weighted by th…
how to divide a column element wise in python
I want to divide the first column of this table element wise by 3.6. enter image description here It throws an error something like : Here’s what I tried: Answer There are several ways to do it, here are two. I suggest from your error message that your data is in a pd.DataFrame. I used a shortened versi…