Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Pandas equivalent to the excel fill handle?

Is there a Pandas function equivalent to the MS Excel fill handle?

Fill Handle from MS Excel

It fills data down or extends a series if more than one cell is selected. My specific application is filling down with a set value in a specific column from a specific row in the dataframe, not necessarily filling a series.

like image 213
DanGoodrick Avatar asked Sep 13 '25 20:09

DanGoodrick


1 Answers

This simple function essentially does what I want. I think it would be nice if ffill could be modified to fill in this way...

def fill_down(df, col, val, start, end = 0, interval = 1):
    if not end:
        end = len(df)
    for i in range(start,end,interval):
        df[col].iloc[i] += val
    return df
like image 134
DanGoodrick Avatar answered Sep 16 '25 12:09

DanGoodrick