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

Merging two dataframes based on a date between two other dates without a common column
Why I can't change the series format?
Copy numpy array into Panda multiindex (same size)
Average Previous and Current Row - Pandas
seaborn pointplot above swarmplot
Edit field and append value to a python dataframe column
column_stack returns non cotiguous array
pandas: conditionally select a row cell for each column based on a mask
pandas custom function apply on melted dataframe
How to check for boolean codition in pandas dataframe
Reading batches of data from BigQuery into Datalab
Jupyter/ipywidgets sorting dataframe on two levels
Groupby.sum() giving ValueError: overflow in timedelta operation
Why does DataFrameGroupBy.boxplot method throw error when given argument “subplots=True/False”?
Calculate age in months - optimize date transformations in pandas
pandas: list of dictionaries grouped by key from df

Categories

HOME
testing
blogger
magnific-popup
minimum-spanning-tree
kde
google-play
react-virtualized
appx
lodash
office365api
sd-card
cplex
jsp-tags
jira
analysis
frameworks
ebean
communication
nano-server
dax
handsontable
resize
windows-azure-storage
decimal
ghc
django-admin
angular-ui
jqwidget
django-cms
reverse-proxy
jasonette
intentfilter
sqlcipher
fish
facebook-access-token
nhapi
fifo
spring-mybatis
minitab
jaxb2
kendo-datasource
instant-messaging
stormpath
semantic-versioning
karaf
noraui
repo
force-layout
picasso
retina-display
eclipse-scout
arena-simulation
import-from-excel
qsslsocket
paxos
worker-thread
font-size
media-player
bind9
asp.net-4.5
google-web-starter-kit
lttng
lua-5.1
ready-api
associative-array
cloudbees
netmq
qtableview
intel-fortran
ora-00900
django-unittest
microbenchmark
clipperlib
c3
dd
asp.net-web-api-odata
onactivityresult
flask-cors
openexr
seaside
kgdb
datagridviewcolumn
itmstransporter
regsvr32
qtkit
window-management
coredump
servicehost
ext3
web-architecture
photoshop-cs4
javap
phonon
port-number
w3wp
django-notification
paul-graham

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