Skip to content
Advertisement

Tag: pandas

Does loc/iloc return a reference or a copy?

I am experiencing some problems while using .loc / .iloc as part of a loop. This is a simplified version of my code: basically: I initialize a dataframe with index and columns I populate each row of the dataframe with a for loop I find the index “i_max” finding the maximum value in column ‘A’ I save the row of

Append only matching columns to dataframe

I have a sort of ‘master’ dataframe that I’d like to append only matching columns from another dataframe to The problem is that when I use df.append(), It also appends the unmatched columns to df. But my desired output is to drop columns D and E since they are not a part of the original […]

How to zip together lists of unequal length into a dictionary?

I have three lists. I’d like to make these lists into a dataframe in which each row is the author paired with each coauthor and the frequency of collaborations. Basically if I could zip these three lists together, with the list ‘author’ replicated over and over in each row, this would be great. This seems […]

matplotlib: draw a box on axes

I want to draw the box between y=75 and 90 (green and red lines on the chart), but nothing is shown up when I do ax.add_patch this is the image I get: So How do I fill out the area between red and green horizontal lines? AdvertisementAnswer If you have a fixed area you want […]

Extracting 2gram strings from a column present in a list

I have a dataframe called df and a list called algorithms So technically, for each row of the Comments column, I’m trying to extract words that appear in the algorithms list. This is what I’m trying to achieve However, this is what I’m getting words like machine learning and fraud detection don’t appear. basically, all […]

A few operations with df.groupby()

I working with a forex dataset, trying to fill in my dataframe with open, high, low, close updated every tick. Here is my code: So as you can see, with for loop I’m getting groups. Now I want to fill the following columns in my dataframe: idx be my df[‘candle_number’] df[‘1h_open’] must be equal to […]

Advertisement