I'm storing patients' daily blood pressure data in an SQLite3 table. Each patient corresponds to a row, each date corresponds to a column. How do I initialize this table with the column names being the dates from a Python Pandas series? Perhaps something like:
DATE_LIST = pandas.date_range(start_date, end_date)
cursor.execute('''CREATE TABLE bloodpressure DATE_LIST REAL''')
The above will create a table with a single column named DATE_LIST, which is not what I want. I want to use the dates in DATE_LIST as column names.
You are breaking the 1NF of databases. Consider restructuring the database to follow the normal form.
In simpler terms, each row should be a patients blood pressure at some date.
patient_id | bloodpressure | date
-----------+---------------+-----------
101 | 120/80 | 2016-08-04
101 | 130/84 | 2016-08-03
102 | 150/90 | 2016-08-03
The SQL statement to create this could look something like
CREATE TABLE bloodpressure (
patient_id integer,
bloodpressure text,
date text,
primary key(patient_id)
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.