0

My code is as follows like this:

   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)

What I get back:

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

I'm still getting duplicate symbols and I can't figure out why

Davtho1983
  • 3,827
  • 8
  • 54
  • 105

0 Answers0