Questions tagged [ffill]

questions related to ffill method of pandas DataFrame or Series objects

Synonym for DataFrame.fillna() with method='ffill'.

Read more here.

See also:

46 questions
0
votes
1 answer

Concert quartile into monthly data for each id while fill other columns by the first month of quarter

I am trying to convert quartiles into month for each unique id in pandas by filling other columns with previous row values. I have seen this one Pandas: Add data for missing months, but it's for only one id(it doesn't work for multiple id), how can…
ash1
  • 393
  • 1
  • 2
  • 10
0
votes
0 answers

ffill() does not fill the last year of observations

I have an issue with Python not filling the months of latest observed year. Does anyone know how to expand the line of code to get the values for all the months of the whole year of 2021? I understand that our df is not any longer than 2021 and…
Angela R
  • 1
  • 1
0
votes
2 answers

Filling in multiple missing date values in pandas dataframe

My dataframe looks like this: data1 = {'date': '2018-09-14', 'base_currency': 'EUR', 'target_currency': ['NZD', 'AUD', 'HKD'], 'exchange_rate': [11.7778,1.6244,9.1755] } data2 = {'date': '2018-09-17', …
Bluetail
  • 1,093
  • 2
  • 13
  • 27
0
votes
1 answer

Error occured when calling ffill in DolphinDB reactive state engine

Please tell me why the error occurred when I called in DolphinDB reactive state engine. I also used select ffill(Ticker) in MySQL and it returned the expected result. //Code…
jinwandalaohu
  • 226
  • 1
  • 7
0
votes
2 answers

backfill a column based on a group pandas

I am working with the following dataframe: df = pd.DataFrame({"id": ['A', 'A', 'A', 'B', 'B', 'B', 'C','C' ], "date": [pd.Timestamp(2015, 12, 30), pd.Timestamp(2016, 12, 30), pd.Timestamp(2018, 12, 30),pd.Timestamp(2015, 12, 30),…
Researcher
  • 149
  • 1
  • 8
0
votes
1 answer

Pandas resample business days and ffill not filling

I have the following test data frame: data date 2021-03-01 3968513.99 2021-03-02 5909640.34 2021-03-03 6452578.11 2021-03-04 7260439.94 2021-03-05 6659379.74 2021-03-08 6693275.88 2021-03-09 …
Simon Nicholls
  • 635
  • 1
  • 9
  • 31
0
votes
1 answer

merging quarterly and monthly data while doing ffill on multiindex

I am trying to merge a quarterly series and a monthly series, and in the process essentially "downsampling" the quarterly series. Both dataframes contain a DATE column, BANK, and the remaining columns are various values either in a monthly or…
0
votes
1 answer

pandas dataframe how to ffill nan columns when number of nan differ between rows

I have a dataframe, when every row might have some nan in the last columns: df = A B C D E F 1 2 3 nan nan nan 1 2 3 4 nan nan 1 2 3 4 5 6 I want to run ffill per row, to get: df = A B C D E F 1 2 3 3 3 3 1 2 3 4 4 4 1 2 3 4 …
Cranjis
  • 1,590
  • 8
  • 31
  • 64
0
votes
1 answer

Python/Pandas: dataframe merge and fillna

I try to merge two Pandas dataframes based on date and then ffill NaN values until specific date. I have the following data…
kobo
  • 35
  • 6
0
votes
2 answers

forward fill (ffill) on a multiindex

This is my dataframe, I have a multiindex on time and ID. +------+-------+----------+-----------+ | col1 | col2 | col3 | col4 | +-------+------+------+-------+----------+-----------+ | ID | t | | …
noiivice
  • 400
  • 2
  • 15
0
votes
4 answers

Python - ffill() with subtraction

I'm trying to fill NAs by using the previous Total and then subtracting the Change Change Total 01/01/2021 -12 100 02/01/2021 -54 154 03/01/2021 -23 177 04/01/2021 -2 NaN 05/01/2021 -54 NaN 06/01/2021 -72 NaN Desired output; …
spcol
  • 437
  • 4
  • 15
0
votes
1 answer

Pandas Fill consecutive null values with range of values between the first non null value before and after

I have a dataframe where I would like to fill null values in a dataframe following two conditions Condition 1: value after NaN (in this example 10) > value before NaN (7.5) 2.75 7.5 NaN NaN NaN 10 Equally increments from 7.5 to 10. So it would be…
Abdelrahman Shoman
  • 2,882
  • 7
  • 36
  • 61
0
votes
1 answer

Forward Fill with Reference to ID column

Suppose I have a dataframe as follows: Roll No | Name | School | Year | Total Marks | Previous Marks ------------------------------------------------------------------------ 1001 | abc | iisr | 2005 | 595 | …
Mujeebur Rahman
  • 189
  • 1
  • 14
0
votes
1 answer

forward fill specific column after groupby and reindex

I would like to fill one specific column, the "id" column with the "id" in that group, and forward fill the other columns with 0 after applying a groupwise reindex. my current version with filling all missing values with 0 looks like this: def…
daniel
  • 1
0
votes
0 answers

fill missing values based on the last value

I want to fill missing values based on the last value of every Id for example , I want this datafarme id value 1 a 1 nan 1 nan 1 b 2 c 2 nan 2 nan 2 d to be id value 1 a 1 b 1 b 1 b 2 c …
rafine
  • 361
  • 3
  • 18