pandas - forward fill method fills extended rows -


forward fill method overwrites 'na' values original file. there way treat "na" literally instead of converting nan while reading file?

!wget https://s3.amazonaws.com/datameetgeo/sample.txt  import pandas pd df=pd.read_csv('sample.txt', sep='\t') df=df.fillna(method='ffill') 

as can seen in above example, value of "c-54465" carried forward next college code 954. wrong , should limited first 22 rows. there way control how ffill works or how "na" values treaded while reading?

by default pd.read_csv interprets na null. can turn off parameter keep_default_na=false

pd.read_csv('sample.txt', sep='\t', keep_default_na=false) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -