Questions tagged [fillna]

Use this tag for pandas.DataFrame.fillna or pandas.Series.fillna

Fill missing values using the specified method for a DataFrame or a Series with pandas (see also interpolate, ffill, bfill)

Docs:

528 questions
0
votes
1 answer

Filling missing data using calculation from existing column data

Running into a small problem. Working on a UCI machine learning repository (ILPD in specific). There are 4 missing values in one column. Rather than impute with the mean or median, it can be worked out using a simple formula from the existing column…
projecthunder
  • 21
  • 1
  • 3
0
votes
0 answers

Issue with using pandas fillna()

I have a DF with cols 'category' and 'fund_size', with fund_size with missing values. Unique values = ['Large', 'Medium', 'Small']. What I am trying to do is - for all unique values is category, get the mode value of fund_size and replace the na…
0
votes
2 answers

python replace nan to zero for specific rows

Hi i have a dataframe like this below, just want to replace nan to zero from third row to sixth row. is there any easy method for this issue? att1 att2 att3 1 1 5.0 1 1 Nan 1 1 4.0 1 2 1.0 2 1 Nan 2 2 3.0 2 2 4.0 to att1 att2 att3 1 1 5.0 1 1…
potatout
  • 187
  • 1
  • 11
0
votes
2 answers

Python fillna based on a condition

I have the following dataframe grouped by datafile and I want to fillna(method ='bfill') only for those 'groups' that contain more than half of the data. df.groupby('datafile').count() datafile column1 column2 column3 column4 datafile1 5 …
0
votes
0 answers

Using fillna with groupby with median but its fill few nan values and rest is same Nan values in the dataset

data = data.fillna(data.groupby(['product_id'], as_index=False).median()) dataset shape is (336666,665). It show 4178 Nan value in 10 columns and few columns have 4.After Executing code its become 3872. Any suggestions regarding this. I have try…
0
votes
0 answers

combine_first for more than one entry

I have two dataframes: df1 & df2 that have 30 columns each. I have a set of 7 columns that are filled with np.nan in df1. I want to use the entries from df2 within those same 7 columns to fill in the df1 nan's within their respective columns. In…
Matt_Davis
  • 259
  • 4
  • 16
0
votes
0 answers

How to fillna() slice of dataset with mode

Please help me understand why this syntax is not working data[data.country == 'SA'].postal_code.fillna(data[data.country == 'SA'].postal_code.mode(), inplace=True) Basically what I want to do is fillna() the postal_code column with the most frequent…
Mengezi Dhlomo
  • 335
  • 1
  • 3
  • 13
0
votes
0 answers

What causes python memory error using fillna()

I am getting the following error numpy.core._exceptions.MemoryError: Unable to allocate array with shape (1329, 22474) and data type float64 This is my code: interactions_df = pd.DataFrame(list(DB[USER_COLLECTION].find({}))) interactions_full_df =…
0
votes
0 answers

Fillna in pandas with respect to similar line

I'm sure this has been answered elsewhere, but I can't think of how to exactly phrase it. I am constructing a dataframe from orders. The way the csv is presented to me is, if the customer ordered more than 1 item, the following line in the csv is…
0
votes
1 answer

Assignment with both fillna() and loc() apparently not working

I've searched for answer around, but I cannot find them. My goal: I'm trying to fill some missing values in a DataFrame, using supervised learning to decide how to fill it. My code looks like this: NOTE - THIS FIRST PART IS NOT IMPORTANT, IT IS JUST…
Federico Dorato
  • 710
  • 9
  • 27
0
votes
2 answers

Imputation of missing values for categories in pandas based on another column

how fill nan values in pandas data frame ? my data like this id state zone xxx AP south xxx AP xxx AP xxx AP xxx delhi north xxx delhi xxx delhi xxx delhi …
0
votes
1 answer

pandas fillna in subset of rows

I've got df as follows: a b 0 1 NaN 1 2 NaN 2 1 1.0 3 4 NaN 4 9 1.0 5 6 NaN 6 5 2.0 7 8 NaN 8 9 2.0 I'd like fill nan's only between numbers to get df like this: a b 0 1 NaN 1 2 NaN 2 1 1.0 3 4 1.0 4 9 1.0 5 …
data_b77
  • 415
  • 6
  • 19
0
votes
2 answers

specifying a limit for fillna has not been implemented yet

I want to implement a fillna method over a pandas dataframes with the method='bfill' and a limit labeled_features = final_feat.merge(failures, on=['datetime', 'machineID'], how='left') print(type(labeled_features)) labeled_features =…
0
votes
2 answers

fillna doens't fill null values

I like to fill the null values in a column with a formel based on other columns: data['datacqtr'].fillna(data['datadate'].dt.year.apply(str) + str('Q')+data['datadate'].dt.quarter.astype(str)) Can you see where the problem is with my Code? Because…
pythoo
  • 27
  • 7
0
votes
3 answers

How to fill Nan values for multiple columns at once?

df Fruits Veg Non_veg 1 Apple Broccoli Chicken 2 Banana Nan Nan 3 Nan Tomato Nan In the above sample data frame, I have Nan values and I need to fill it with forward filling all at once and the code I used is…
jain
  • 113
  • 2
  • 12