Skip to content

Tag: python

How do you run a function to compare two date by month?

I’m trying to run a function to compare today’s month with the month input by a user. The dates will be input by the user as ‘YYYY-MM-DD’. This is what I have so far: But get the following error: fromisoformat: argument must be str So I tried using the following function instead with s…

Pandas – Count repeating values by condition

Dataframe: I have columns “group” and “val” and I don’t know how to write pandas code to get column “count”? The logic is like this, it should count the number of consecutive values that are on the same side (either positive or negative) grouped by column “group…

Does mongo db ListField maintain ordering?

If I add items to a ListField on a mongo db document in a specific order and then write it to the database, is it guaranteed that all subsequent reads will see the list in the same order? e.g. write read this is using python mongoengine ORM v0.4.2 Answer Yes they do, the driver is faithful to the underlying d…

Websocket Json Data to DataFrame

I am learning how to work with APIs and web sockets in finance. My goal for this code is to access data and create a DataFrame with only columns (index, ask, bid & quote) I have tried appending values to the DataFrame but it creates a new DataFrame every time I receive a message similar to the df = new_df…