I have been working on a dataframe where one of the column (flight_time) contains flight duration, all of the strings are in 3 different formats for example: “07 h 05 m” “13h 55m” “2h 23m” I would like to change them all to HH:MM format and finally change the data type from…
Tag: python
My code outputs everything right but it doesnt exit after finding out an error
question sample input outputs to check, an input is 221, 1, 7 the output shud be invalid move as the 7th position of 0000221 is 1 already not 0 so it shud be an invalid move which my validation checker does correct except after that it still prints out the whole thing because there is no error with printing i…
How can I return a sorted list of integers here? [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 12 months ago. Improve this question My problem is on the last line. In the last line, I wanted to return 4, 8, 9, 10 but it…
How to highlight whole syntax(including every modules’s Keywords,class,etc.) of python in text widget in python tkinter
I am creating code editor, I want to highlight every code properly. I have created a code to highlight code and I have created a different function to highlight string and comments but when I type any code from which already contain some color to highlight doesn’t show string color inside “”…
name ‘Bidirectional’ is not defined
Im following this tutorial and right when I want to initialize a sequential keras, like the code below: I get an error saying : What is the problem ? it is the exact same code as in the tutorial. Answer You’re most likely missing the import statement from the tensorflow package. It appears that’s there is a l…
Different results when running C program from Python Subprocess vs in Bash
I’ve got a string/argument that I’d like to pass to a C program. It’s a string format exploit. However, there seems to be different behaviours exhibited if I call the C program from Python by doing versus The difference is that the string exploit attack works as expected when calling the scr…
Random walk generate OverflowError: cannot convert float infinity to integer
I edited a chuck of random walk code from this link (ps: the orginal one works): But my edited version throw out an error: OverflowError: cannot convert float infinity to integer, does someone could help to fix this issue? Thanks in advance. Answer Well, x[i] can be as large as 10, and so can y[1], so can be …
Kernel dies when processing DataFrame
I’ve been able to get this to execute once but since then the kernel just hangs and then dies. Any help would be appreciated. [Dataframe head] Answer You might want to consider using .apply() function from pandas directly with a custom function or a lambda expression. Something like this I do not see an…
Linear sum assignment (SciPy) and balancing the costs
I am having difficulty using scipy.optimize.linear_sum_assignment to evenly distribute tasks (costs) to workers, where each worker can be assigned multiple tasks. The cost matrix represents the workload of each task for each worker. We want to minimize the total costs of all workers, while evenly distributing…
Pandasql Exception with OVER
I tried to use this line of code : NB : delete ‘locals()’ or replace by ‘globals()’ don’t solve the problem. But I have this error : http://sqlalche.me/e/14/e3q8 (Same error with Average) I load my dataframe like this : My file is in the same directory as my Jupiter notebook file…