Skip to content

While loop with missing data handling

I would like to loop over a file where there is an date index and values. Looping backward would help to prevent checking a date where there is no data. So it should stop as it find the first date. I set a today date, change into the appropriate format that correspond to the date in the file, try to

emptying JSON file

I want to completely empty a JSON file, while still keeping the file. How do I do that? I tried: , etc but none of them work. Please help me out! Ive seen answers on how to delete keys in the JSON, or delete the entire file, but not how to just replace it with nothing. Answer You can just

Pandas add missing weeks from range to dataframe

I am computing a DataFrame with weekly amounts and now I need to fill it with missing weeks from a provided date range. This is how I’m generating the dataframe with the weekly amounts: Which outputs: If a date range is given as start=’2020-08-30′ and end=’2020-10-30′, then I wou…

Creating multiple graphs using gnp_random_graph

While using the NetworkX package I was tasked with creating multiple random graphs with a given n number of nodes and p probability, this is my code: But, every iteration creates the same exact graph (even the edges are completely the same) Does anyone have a clue what might be wrong? Update: After trying to …