Skip to content

Tag: dataframe

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&#8217…

difference between “&” and “and” in pandas

I have some code that runs on a cron (via kubernetes) for several months now. Yesterday, part of my code didn’t work that normally does: This statement, all of a sudden, wasnt ‘True’ (both df_temp and df_temp4 have data in them: however, this worked: Was there some sort of code push that wou…

Search for a value anywhere in a pandas DataFrame

This seems like a simple question, but I couldn’t find it asked before (this and this are close but the answers aren’t great). The question is: if I want to search for a value somewhere in my df (I don’t know which column it’s in) and return all rows with a match. What’s the most…

Using result_type with pandas apply function

I want to use apply on a pandas.DataFrame that I created, and return for each row a list of values, where each value is a column in itself. I wrote the following code: When I add result_type=’expand’ in order to change the returned array into separate columns I get the following error: However if …