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: reindex multiindex, broadcast results
TypeError when changing an integer data series in pandas
Pandas file IO Read Error
Pandas — asof() by last on DataFrame
Pandas Column Construction with np.where()
MultiIndex-based indexing in pandas
How to get the number of the most frequent value in a column?
Using pandas.ols on multiple dependent variables at once
Insert 0-values for missing dates within MultiIndex
Reindexing dataframes
pandas access axis by user-defined name
Trouble with groupss and aggregation
Replace MultiIndex's contents with DataFrame columns
What's the `DataFrameGroupBy`-equivalent of `dict.keys`?
How to split a dataframe according to a boolean criterion?
Pandas Rolling Computations on Sliding Windows (Unevenly spaced)

Categories

HOME
gitlab
amazon-ec2
openstack
isabelle
layout
portia
multiple-records
append
adobe-analytics
node-pdfkit
postgres-xl
windows-azure-storage
alignment
messages
quickfix
uitypeeditor
telephony
django-admin
transformation
ef-migrations
firefox-webextensions
tokenize
cloudhub
mps
php-openssl
phpfox
fgetcsv
publish
saas
bcd
.net-4.0
scorm2004
catch-all
uiswipegesturerecognizer
mozilla
gammu
mmenu
mapdb
c11
temporary-files
elasticsearch-plugin
particles.js
elmah
ibpy
gpx
businessworks
btrace
galleria
cubic-spline
user-accounts
react-scripts
prolog-setof
fancybox-2
diagnostics
boost-preprocessor
namecoin
lync-client-sdk
color-picker
google-feed-api
elements
skobbler-maps
bgp
independentsoft
wordml
interrupted-exception
sniffer
mmc
web-controls
kineticjs
facebook-graph-api-v2.4
sorl-thumbnail
operator-precedence
rdl
starcluster
doskey
hippomocks
algebraic-data-types
viadeo
soundtouch
batterylevel
gdata-api
runas
osql
amazon-appstore
semantic-diff
asyncfileupload
code-cleanup
hgsubversion
genshi
multi-tier
procedural-music

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