Skip to content

Tag: dataframe

How to sum a value based on group?

I am trying to figure out how to sum a value from rank 5 to the LOWEST rank (I.E. 5-1,000) for each geography in my dataframe. However, I am getting the error: ‘DataFrameGroupBy’ object has no attribute ‘iloc’ Am I using iloc incorrectly? Answer IIUC, try:

Resolving conflicts in Pandas dataframe

I am performing record linkage on a dataframe such as: When my model overpredicts and links the same ID_1 to more than one ID_2 (indicated by a 1 in Predicted Link) I want to resolve the conflicts based on the Probability-value. If one predicted link has a higher probability than the other I want to keep a 1 …

Merge 2 columns from a single Dataframe in Pandas

I want to merge 2 columns of the same dataframe, but by using some specific condition. consider the following dataframe : number-first Number-second 1 Nan 2 4C 3A 5 Nan 6 Nan 7 Nan Nan The conditions are: If the Number-first column has a alphanumeric value and the Number-second Column has a Nan value or a &#8…

Y finance Date alignment

This might be a relatively difficult question; The scope of the code I want to write, is to automate the alignment of Dates that i pull from yfinance regarding BTC and S&P 500 since the S&P500 (SPY) is not traded on weekends, but BTC is, I want to automatically delete the columns of dates from BTC tha…

Changing column various string formats in pandas

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…