Skip to content

How to type hint a function’s optional return parameter?

How do I type hint an optional output parameter: — edit This seem to work: but that is so ugly and seems to overwhelm the fact that typically it will only return a simple float. Is that the correct way to do this? See answer below for correct way. — edit 2 This question was flagged as duplicate of…

Change a column format while ignoring (or keeping) NaN

I want to change a column from a DataFrame which contains values of this format hh:mm:ss to a column containing the number of minutes (while keeping the NaN values) I can’t change it directly from the excel file so I’ve tried to do it with pandas (I’m working on a ML model with a health data…

How to enter something into a program without arguments?

I am facing trouble with a code that I am working on. #1 code #2 code Now like the situation is that I want to use #1 code in #2 code, but as the #1 code doesn’t have arguments, i cant do ./start.py -i wlan0 or anything like that. Is there any other way round? Or just arguments. Note: I

Have only 1 record per date in a pandas dataframe

Background: In mplfinance, I want to be able to plot multiple trade markers in the same bar. Currently to my understanding you can add only 1 (or 1 buy and 1 sell) to the same bar. I cannot have 2 more trades on the same side in the same bar unless I create another series. Here is an example: df