Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get first not null value from column dataframe

s = pd.Series([np.nan,2,np.nan])
print (s)
0    NaN
1    2.0
2    NaN
dtype: float64

print (s.first_valid_index())
1

print (s.loc[s.first_valid_index()])
2.0

# If your Series contains ALL NaNs, you'll need to check as follows:

s = pd.Series([np.nan, np.nan, np.nan])
idx = s.first_valid_index()  # Will return None
first_valid_value = s.loc[idx] if idx is not None else None
print(first_valid_value)
None
Comment

PREVIOUS NEXT
Code Example
Python :: re.search 
Python :: what is in the python built in namespace 
Python :: re sub python 
Python :: pure imagination 
Python :: django convert model to csv 
Python :: pandas drop 1970 
Python :: keras backend matrix multiplication 
Python :: remove rows from a dataframe that are present in another dataframe? 
Python :: color module python 
Python :: minio python create bucket 
Python :: fit function tensorflow 
Python :: binary search tree python 
Python :: pandas select multiple columns 
Python :: aws django bucket setting 
Python :: python dict to string 
Python :: making your own range function with step in python 
Python :: node 14 alpine add python 
Python :: python get output 
Python :: how to print tables using python 
Python :: update in django orm 
Python :: python unittest multiple test cases 
Python :: python compare dates 
Python :: reactstrap example 
Python :: python sounddevice stop recording 
Python :: python projects 
Python :: import excel 
Python :: how can I convert dataframe to list with in python without changing its datatype? 
Python :: graph implementation in python 
Python :: get resolution of image python 
Python :: string format method python 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =