I have two different dates and I want to know the difference in seconds between them. My data: I want to add two column to my data frame: My code: This is the error: Answer Use .dt.total_seconds() Ex: Output:
How to connect to HTTPS connection to use an API in Python?
This is the requirement from the API’s documentation A HTTPS connection is needed to use the API. This means that you will require a secure SSL/TLS connection to be able to communicate with our API Server. This is the Curl command of getting the clients in their documentation So, I need to implement the…
How to make a circle using PIL?
As the title says I want to draw a circle in PIL but the output isn’t a circle The output: https://i.stack.imgur.com/qlYmD.png Code: I want to know how can I fix this problem. Answer To draw a circle of radius 50 with center at (150,150): To the ellipse you have to provide Two points to define the bound…
How to write more than one text inside of a variable [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 12 hours ago. Improve this question Hey Guys im new to Python and programming in general and i was creating little guessing…
Decision tree with a probability target
I’m currently working on a model to predict a probability of fatality once a person is infected with the Corona virus. I’m using a Dutch dataset with categorical variables: date of infection, fatality or cured, gender, age-group etc. It was suggested to use a decision tree, which I’ve alread…
How to extract certain string out of long url kind of string in python using pandas
How to use regex in pandas to extract below field. the below is one of my pandas dataframe column value, but i wanted to only extract ‘eastus’ and keep it as value for this field. how to filter this. this position is always fixed Sample df: command i tried: but its not working Error: any suggestio…
pushing and poping into new list
I am trying to make a loop that if the program sees a letter or number it will push(x) into a new list and if it sees an asterisk * it must pop(). It is more of a stack algorithm where the first letter or number in is the last one out. FILO First in last out For example If
Remove commas from all columns except one
Is there a way to remove commas from all columns except 1 or 2 (here, just date) in general code? (I have 20 columns in reality.) Expected output: Answer Use DataFrame.replace on columns of dataframe excluding the columns from exclude list: Result:
Why cant I login into a website using request module
So I needed to login to a website as I need to do an action that requires logging in first. Here’s my code: it gives me the title of when you’re not logged in :( Answer I’m not sure why did I flagged this as duplicate, sorry. Okay, so I created a dummy account and tried logging in – I
How to convert Array to pandas dataframe with datetime ohlcv efficiently, also divide column values by 100?
Following is the json output I am getting from api I want to convert this json/array to timestamp, ohlcv data which has DateTime index and the ohlc values must be divided by 100 or sometime by 10000 depending upon the ticksize. The final output must look something like below: I know the answer is available on…