How to convert Pandas DataFrame to xts and ts TimeSeries

It is very convenient to collect and slice various data streams using MongoDB and Pandas (mentioned here). However, since I recently had been reading this wonderful Rob J Hyndman's R course on forecasting, I realized that I need to be able to be able to convert Pandas DataFrames to R's xts and ts objects. I found these great slides by Jared P. Lander, and here is how:

from pandas import DataFrame, read_csv
# Read some DataFrame with TimeSeries data (I take the AAPL stocks)
X = read_csv('', parse_dates=True)
# function to load pandas DataFrame into R
# written by Wes McKinney
def pandas_to_r(df, name):
    from rpy2.robjects import r, globalenv
    r_df = rpy.convert_to_r_dataframe(df)
    globalenv[name] = r_df
# Send it to R
pandas_to_r(X, "df")
# convert to date
df$Date <- as.Date(as.character(df$Date))
df$Close <- as.numeric(df$Close)
df.xts <- xts(df$Close,$Date)

Now, in my case, the course mostly deals with ts series object, we can do it with extra line:

df.ts <- as.ts(align.time(df.xts,1))

F & P