pandas


pandas dataframe interpolate


So I see that there is a way to interpolate for a pandas series object http://pandas.pydata.org/pandas-docs/dev/generated/pandas.Series.interpolate.html. Is there an equivalent method for dataframes? I'd like to interpolate every column.
Normally different columns in a pandas DataFrame contain different type of information, so an interpolation method may not apply or you may need different methods depending on the data.
Supose a DataFrame called data, with columns 'TimeStamp', 'Lat', 'Lon', 'Value'. You can interpolate NaN values of each column by doing:
data.TimeStamp = data.TimeStamp.interpolate(method = 'time')
data.Lat = data.Lat.interpolate(method = 'spline')
data.Long = data.Long.interpolate(method = 'spline')
data.Value = data.Value.interpolate(method = 'linear')
If the data in all your columns are homogeneous, I suppose you can call the same method for all of them.
More information about the interpolate function:
http://pandas.pydata.org/pandas-docs/dev/generated/pandas.Series.interpolate.html
I just tried it in pandas 0.13, and it works:
a = Series([0,nan,1,2])
b = DataFrame([a,a,a,a])
b
0 1 2 3
0 0 NaN 1 2
1 0 NaN 1 2
2 0 NaN 1 2
3 0 NaN 1 2
b.interpolate(axis=1)
0 1 2 3
0 0 0.5 1 2
1 0 0.5 1 2
2 0 0.5 1 2
3 0 0.5 1 2

Related Links

change value (string manipulation) in Pandas DataFrame
Trying to implement networkx into graphicsscene
Merge two data frames based on common column values in Pandas
Combine two columns of numbers in dataframe into single column using pandas/python
Python Pandas has low CPU usage and not using all cores
Pandas Set on copy warning when using .loc
Merge very large csv using pandas or awk
seasonal_decompose: operands could not be broadcast together with shapes on a series
How to properly sample from a numpy.random.multivariate_normal (positive-semidefinite covariance matrix issue)
how to do logical operation between dataframe columns?
Console hangs up at the time of plotting
Pandas apply a function at fixed interval
float type column in pandas to convert to tuple/list
Getting an error with Pandas Panel boolean indexing
pandas dataframe subtraction causing nan
Pandas dataframe: truncate string fields

Categories

HOME
ibm-bluemix
pandas
winforms
gitlab
pypi
nullpointerexception
smarty
iterator
razor
react-redux
leon
disassembler
ckeditor
medical
awesome-wm
session-variables
windows-10-universal
quickbooks
phaser
clojurescript
systemc
foselasticabundle
oracle-coherence
excel-vba-mac
contextmenu
jtextfield
excel-2007
blazemeter
java-7
facebook-access-token
entitlements
publish
typo3-6.2.x
buck
compatibility
facebook-apps
large-file-upload
primitive
instant-messaging
directx-10
winrt-xaml-toolkit
pim
avcapturesession
bitbucket-pipelines
withings
cookiecutter-django
optix
nand2tetris
outlook-api
apple-news
long-polling
jedis
yii2-extension
setter
jxcore
windows-mobile-6.5
ifs
dstu2-fhir
phishing
plottable.js
bstr
player
actionbardrawertoggle
bluegiga
revolution-r
xpath-1.0
phpcas
separator
mono-embedding
createprocessasuser
unity5.2.3
skos
apache-commons-net
system.reflection
fscommand
website-monitoring
qpainter
cdt
java.util.concurrent
issuu
responsive-slides
kgdb
page-layout
eclipse-memory-analyzer
mqx
interface-orientation
flashvars
wsdl-2.0
itmstransporter
sublist
rdoc
newtonscript
regsvr32
semantic-diff
hgsubversion
window-management
zpt
subgurim-maps
xfbml
digest-authentication
icanhaz.js
nerddinner

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App