I'm reading a single JSON line from file data.json with this content:
[
{
"timestamp": 1436266865,
"rates": {
"EUR": 0.911228,
"JPY": 122.5463,
"AUD": 1.346118
}
},
{
"timestamp": 1436277661,
"rates": {
"JPY": 122.4789,
"AUD": 1.348871,
"EUR": 0.91433
}
}
]
into a pandas DataFrame. I want to use the "timestamp" as the DataFrame's index. I achieve this by:
df = pandas.read_json('data.json')
df.index = df['timestamp']
df.drop('timestamp', axis=1, inplace=1)
Is it possible to do it in just one line?