• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: fill missing value based on index

Resolved: fill missing value based on index

0
By Isaac Tonny on 17/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

i try to percentace missing value like this
and filter like this

null_column = null[(null>= 10.0) & (null <= 40.0)].index [/code]

the output type is index
how can i using fillna to replace median in every column based on index
my code before like this

null_column = null[(null>= 10.0) & (null <= 40.0)].index data.fillna(percent_column2.median(), inplace=True) [/code]

the result always

index doesnt have median


but when i deleted index it works but the median that replaced is not median in every column. But, median that 2 values of percentage missing value not in original dataframe. How can i fill nan value based on index to replace in original data frame?

Answer:

I guess something like this:

data = pd.DataFrame([[0,1,np.nan],[np.nan,1,np.nan],[1,np.nan,2],[23,12,3],[1,3,1]])
cols = list(null[(null>=10) & (null<=40)].index) data.iloc[:, cols] = data.iloc[:, cols].fillna(data.iloc[:, cols].median(), inplace=False) [/code]

If you have better answer, please add a comment about this, thank you!

fillna indexing isnull missing-data python
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: How can I copy files using the ansible.builtin.copy module and avoid conflicting file names?

26/03/2023

Resolved: Reshape tensors of unknown shape with tf.function

26/03/2023

Resolved: Use Svelte Component as Slot

26/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.