I import csv table into JUPYTER NOTEBOOK, and something wrong is happening when I try to iloc a video views column (К-ть переглядів). I need to format this cell to INT type (using .astype()), but it tells me that there is an error: ValueError: invalid literal for int() with base 10: ‘380xa0891xa0555R…
Turning a list into a dictionary adding headers
I’d like to turn the following list in a dictionary: I’d like to add the following headers. Each element of the list needs to have its own header. This is my code: And the following is my output. I obtain the dictionary only for the first element of the list and I can’t understand why. Answe…
How to concate a column’s sentences for same subject id in a single row in python dataframe?
if I have a dataset like- As output, I want that the Drug name with the same Subject_ID will concatenate in one row. How can I do that in Python pandas? Answer Group the dataframe by Subject_ID then call agg with ‘, ‘.join as aggregate for DRUG column, and first as aggregate for LOS column.
aiohttp has different response to http.client in Python request to API
Context: This works: This does not. It returns { ‘error’:’invalid_client’ }. Question: I cannot understand what the difference is between them. Any ideas what might be happening? I’ve also tried: Adding headers to the ClientSession(headers=headers) too. Using the URL and removing…
Check if any element of a list is in a matrix?
I have a small list: and I have a matrix too. for example: And I need to determine if any of the elements of l ist2 of this array are not in the matrix2. I try to use np.isin() : But this code only shows if there is the elements in the matrix or not completely. But I need this
botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL
I am using boto3 to read many text files in S3 through a Lambda Python function. My codes for the connection to S3 below About 30 text files are successfully ok. But after, it gets below error message Any way I can resolve this? Answer Lambda in a VPC does not have public IP and therefor can’t access in…
All combinations of a row in a dataframe
i have the following Dataframe (df = ) with around 40 mio rows. i try to have the following output: at first i thought to use itertools combinations, it.combinations(Colors[“Colors”],2), but the problem was, that it gives me the combinations of the whole column and don’t correlate to the col…
Wanting to input bowling scores, total, average them
Need for a user to input bowling scores and store them, to be totaled and averaged later and they can press “q” or “Q” to quit and total/average them. I’ve tried fumbling around figuring out loops but not sure how to deal with inputting integers and also accepting “Q”…
sorting in pandas, while alternating between ascending and descending on the same sorting column
I would like to sort a dataframe by a two columns, but one is always ascending, and the other switches between ascending and descending based on the value of the first column. In other words, when the first column increases, the sorting flips from ascending to descending or vise versa. My motivation for this …
Discord.py AttributeError(“‘NoneType’ object has no attribute ‘roles'”)
This bot gives out a role when you click on a reaction in a message, when you delete a reaction, it takes it away, this code worked a year ago and there were no problems, now I run it and get I tried to look on the Internet and it seems that I have everything right, I don’t understand where