5

There are a few quick improvements you can make. First, always remove as many things as possible from for loops. In this case, the date formatting and the open file lines can be removed. Dates. Format the dates in your dataframe before the first for loop with something like df['Date'] = pd.to_datetime(df['Date']).dt.date Notice I’m converting the datetime ...


4

Review Function hasAceInHand could be boiled down to a one-liner using array.find. It returns the first element of the array that passes the condition x => x.face === "A" provided. const hasAceInHand = (cardsOnHand) => { return cardsOnHand.find(x => x.face === "A") != null; } Function countHandValue iterates the items, and calls the other ...


3

The way to process recursively nested data is with recursively nested code. I don't know Python, and I would do this in XQuery or XSLT by preference, but the pseudo-code is the same whatever the language: function deep_process (parent, table, level) { for child in parent.children() { shallow_process(child, table, level) deep_process(...


3

I'd suggest using for...of loops to iterate over the cards, but before we can do that, there is an important point with the dealOneCardToPlayer() function: tempCard = deck.cards.splice(0, 1); Note that Array.splice() returns "An array containing the deleted elements."1 and thus the name tempCard is misleading - perhaps a more appropriate name would be ...


1

You repeat a lot of work in each loop. A simple one is extracting the tumor_sizes from the lists. Each row you do sizes = np.array(list(compare_df['tumor_size'])). If you do tumor_sizes = df["tumor_size"].apply(pd.Series) at the beginning of the calculation, you have a series with all tumorsizes, indexed the same as your df. You can save your results in a ...


Only top voted, non community-wiki answers of a minimum length are eligible