我的代码如下:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
forex_11 = pd.read_csv('FOREX_20180111.csv', sep=',', parse_dates=['Date'])
forex_12 = pd.read_csv('FOREX_20180112.csv', sep=',', parse_dates=['Date'])
time_format = '%d-%m-%Y'
forex = forex_11.append(forex_12, ignore_index=False)
forex['Date'] = forex['Date'].dt.strftime(time_format)
# print(forex)
forex = forex.loc[forex.groupby("Symbol")["Open"].idxmax()]
# forex = forex.drop_duplicates(subset=['Symbol'], keep='first', inplace=False)
print(forex)
我得到了什么:
Symbol Date Open High Low Close Volume
0 AEDAUD 11-01-2018 0.3470 0.3470 0.3448 0.3448 0
0 AEDAUD 12-01-2018 0.3448 0.3459 0.3448 0.3456 0
1 AEDCAD 11-01-2018 0.3415 0.3419 0.3408 0.3408 0
1 AEDCAD 12-01-2018 0.3408 0.3415 0.3408 0.3410 0
2 AEDCHF 11-01-2018 0.2663 0.2665 0.2656 0.2656 0
2 AEDCHF 12-01-2018 0.2656 0.2657 0.2647 0.2647 0
我仍然得到重复的符号,我无法弄清楚为什么