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

Pandas Apply(), Transform() ERROR = invalid dtype determination in get_concat_dtype
Pandas Dataframe timeseries
Pandas - understanding output of pivot table
Pandas Group By With Running Total
Python pandas json 2D array
rename columns function not working in pandas
Number format column with pandas.DataFrame.to_csv()?
Matplotlib Subplot Labels Disappear
Counting rows between dates in pandas with groupby
Taking second last observed row
retrieve data from pandas dataframe if it doesn't cooccur in previous column
pandas resample MAX-VALUE with corresponding ANGLE-VALUE
Performance issues with writing data to HDFStore
Finding same value index of pandas Series
Get Maximum Value from Dataframe
Slicing in group by function

Categories

HOME
compiler-construction
yii2
nullpointerexception
react-virtualized
hp-exstream
electron
youtube-dl
xmpp
sqlite-net-extensions
maven-3
graphql
networkx
bs4
dax
leiningen
visual-studio-2005
try-catch
finite-automata
evopdf
custom-wordpress-pages
immutable.js
bootstrap-tour
rundeck
sqlcipher
buildbot
info.plist
saas
subdomains
instant-messaging
lightswitch-2013
fog
code-contracts
mmenu
mpmediaquery
picasso
wpf-controls
android-ble
dosbox
adobe-premiere
twitch
ws-security
google-closure
jvm-languages
fakeiteasy
http-redirect
sencha-touch-2.3
dotcover
pnotify
darcs
windows-mobile-6.5
capacity
linode
sonarlint-vs
eventkit
pycaffe
deadbolt-2
pcf
py2app
fuzzy-search
markojs
skype4py
iad
jms2
endeca-workbench
responsive-images
twirl
appfabric-cache
processmodel
sniffer
google-style-guide
android-imagebutton
websocket4net
heisenbug
tld
hyprlinkr
ember-charts
centos5
gridcontrol
comaddin
limejs
specification-pattern
tinn-r
funscript
javaspaces
netbeans-6.9
semantic-diff
punbb
custom-backend
joyent
celltable
bespin
nerddinner
aquaticprime
spec#
scripting-languages

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