diff options
| -rw-r--r-- | python/bbg_prices.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/python/bbg_prices.py b/python/bbg_prices.py index da83019f..6299fd1e 100644 --- a/python/bbg_prices.py +++ b/python/bbg_prices.py @@ -34,13 +34,15 @@ with conn.cursor() as c: df.iloc[i]['CALLED_DT'], df.iloc[i]['LN_ISSUE_STATUS'], df.iloc[i]['id_bb_unique'])) conn.commit() -currentdata = pd.Index(pd.read_sql_query("SELECT id_bb_unique, pricingdate from bloomberg_corp", - engine, - parse_dates=["pricingdate"])) +currentdata = pd.read_sql_query("SELECT id_bb_unique, pricingdate from bloomberg_corp", + engine, + parse_dates=["pricingdate"], + index_col=['id_bb_unique', 'pricingdate']) #no need to insert empty prices df.dropna(subset=['PX_LAST'], inplace=True) df.set_index(['id_bb_unique', 'LAST_UPDATE_DT'], inplace=True) -df = df.ix[df.index.difference(currentdata)] +df = df.ix[df.index.difference(currentdata.index)] +df.index.names = ['id_bb_unique', 'LAST_UPDATE_DT'] df.reset_index(inplace=True) sqlstr = "INSERT INTO bloomberg_corp VALUES(%s, %s, %s, %s, %s, %s)" |
