<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Convert to and from Pandas DataFrames
There are no built in methods for the conversions but these functions below should work in most basic instances.
Step2:  Raccoon to Pandas
Step4:  Pandas to Raccoon
<ASSISTANT_TASK:>
Python Code:
# remove comment to use latest development version
import sys; sys.path.insert(0, '../')
import raccoon as rc
import pandas as pd
Explanation: Convert to and from Pandas DataFrames
There are no built in methods for the conversions but these functions below should work in most basic instances.
End of explanation
def rc_to_pd(raccoon_dataframe):
    
    Convert a raccoon dataframe to pandas dataframe
    :param raccoon_dataframe: raccoon DataFrame
    :return: pandas DataFrame
    
    data_dict = raccoon_dataframe.to_dict(index=False)
    return pd.DataFrame(data_dict, columns=raccoon_dataframe.columns, index=raccoon_dataframe.index)
rc_df = rc.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]}, columns=['a', 'b'], index=[7, 8, 9])
print(type(rc_df))
print(rc_df)
pd_df = rc_to_pd(rc_df)
print(type(pd_df))
print(pd_df)
Explanation: Raccoon to Pandas
End of explanation
def pd_to_rc(pandas_dataframe):
    
    Convert a pandas dataframe to raccoon dataframe
    :param pandas_dataframe: pandas DataFrame
    :return: raccoon DataFrame
    
    columns = pandas_dataframe.columns.tolist()
    data = dict()
    pandas_data = pandas_dataframe.values.T.tolist()
    for i in range(len(columns)):
        data[columns[i]] = pandas_data[i]
    index = pandas_dataframe.index.tolist()
    index_name = pandas_dataframe.index.name
    index_name = 'index' if not index_name else index_name
    return rc.DataFrame(data=data, columns=columns, index=index, index_name=index_name)
pd_df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]}, index=[5, 6, 7], columns=['a', 'b'])
print(type(pd_df))
print(pd_df)
rc_df = pd_to_rc(pd_df)
print(type(rc_df))
print(rc_df)
Explanation: Pandas to Raccoon
End of explanation
<END_TASK>