Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

fillna with index

In [13]:
d=pd.DataFrame(index=['A','B','C'], columns=['Num','Name'], data=[[1,'Andrew'], [2, np.nan], [3, 'Chris']])
d['Name']=d['Name'].fillna(d.index.to_series())
d

Out[13]:
   Num    Name
A    1  Andrew
B    2       B
C    3   Chris
Comment

PREVIOUS NEXT
Code Example
Python :: music distorted on discord 
Python :: how to display items on a list on new lines python 
Python :: how to count number from 1 to 10 in python 
Python :: python telegram bot async 
Python :: python startswith method 
Python :: convert all sizes to terabytes pandas 
Python :: tkinter label border color 
Python :: split string by special characters python 
Python :: python np.sum 
Python :: find a character in a string python last 
Python :: multiple logger instances populating single log python 
Python :: python re split 
Python :: python vim auto indent on paste 
Python :: webpage with aiohttp 
Python :: python replace negative infinity 
Python :: Uninstalling/removing a package is very easy with pip: 
Python :: gfg placement course 
Python :: SciPy Spatial Data 
Python :: python type casting 
Python :: how to put space in between list item in python 
Python :: python for loop range 
Python :: return array of sorted objects 
Python :: Send Fetch Post With Data Using Body 
Python :: python variables 
Python :: flask orm update query 
Python :: concatenacion python 
Python :: pandas is nattype 
Python :: get maximum value index after groupby 
Python :: extracting values in pandas 
Python :: use a library in python 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =