Skip to content
Snippets Groups Projects
Commit 3896f2f1 authored by Peter Morstein's avatar Peter Morstein
Browse files

parse dataframe id to extra station_id column

parent d4c12775
No related branches found
No related tags found
No related merge requests found
......@@ -144,6 +144,7 @@ def create_matrix_data(cursor, amount_points):
def createInsertStatement(station_list):
# create INSERT INTO table (columns) VALUES('%s',...)
station_list.columns.astype(str)
df_columns = list(station_list)
station_list = station_list.round(decimals=3)
values = "VALUES({})".format(",".join(["%s" for _ in df_columns]))
......@@ -166,8 +167,10 @@ def insert_data(station_list, cursor):
# for column in df_columns:
# columns.append('"' + column + '"')
#columns = str(columns).replace('[', '').replace(']', '').replace("'", "").replace('\n', '').replace(' ', '')
station_list["station_id"] = station_list.index
station_list = station_list.round(decimals=3)
# create VALUES('%s', '%s",...) one '%s' per column
#values = "VALUES({})".format(",".join(["%s" for _ in df_columns]))
......
......@@ -92,6 +92,7 @@ class TestExportToDatabase(unittest.TestCase):
with open("./dataacquisition/pickle/stationList_with_temperature.pickle", "rb") as pickleFile:
stationList = pickle.load(pickleFile)
stationList = stationList.loc[stationList['country']=="Germany"]
stationList["station_id"] = stationList.index
insert_stmt = cut.createInsertStatement(stationList)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment