In [1]:
from __future__ import print_function
import json
import pandas as pd
def print_dict(dd):
print(json.dumps(dd, indent=2))
In [2]:
raw_data = {
'column_1': [1, 2, 3, 4, 5],
'column_2': ['a', 'b', 'c', 'd', 'e'],
}
print_dict(raw_data)
In [3]:
df = pd.DataFrame(raw_data)
df
Out[3]:
In [4]:
df['ind'] = [0, 1, 2, 3, 4]
df
Out[4]:
In [5]:
df.set_index('ind')
Out[5]:
In [6]:
df
Out[6]:
In [7]:
df.set_index('ind', inplace=True)
df
Out[7]:
In [8]:
df = pd.DataFrame(
raw_data,
index=[0, 1, 2, 3, 4]
)
df
Out[8]:
In [9]:
df.index.name = 'ind'
df
Out[9]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: