我有熊猫数据
df = pd.DataFrame({
'country': ['USA', 'USA', 'Belarus', 'USA'],
'population': [17.04, 143.5, 9.5, 45.5],
'square': [2724902, 17125191, 207600, 603628],
'time with timestamp': ['2018-12-03 16:02:06.948083+00:00', '2018-12-03 16:10:25.625414+00:00', '2018-12-03 15:57:54.850205+00:00', '2018-12-03 15:57:54.850205+00:00']
})
df2 = data[data['country'] == 'USA']['country', 'time with timestamp']
print(df2)
`
df = pd.DataFrame({
'country': ['USA', 'USA', 'Belarus', 'USA'],
'population': [17.04, 143.5, 9.5, 45.5],
'square': [2724902, 17125191, 207600, 603628],
'time with timestamp': ['2018-12-03 16:02:06.948083+00:00', '2018-12-03 16:10:25.625414+00:00', '2018-12-03 15:57:54.850205+00:00', '2018-12-03 15:57:54.850205+00:00']
})
df2 = df.loc[df['country'] == 'USA', ['country', 'time with timestamp']]
df3 = df2.sort_values("time with timestamp")
print(df3)
print(df3.loc[:, ['country', 'time with timestamp']])
`