Last active
August 29, 2015 14:04
-
-
Save vilterp/bb820e9ced0b65a31f73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write_to_db(conn, file): | |
df = pd.read_csv(file, parse_dates=[1]) | |
df2 = df.rename(columns={'dataid': 'house_id', 'use': 'total_energy'}) | |
df3 = df2.fillna(0) | |
df3.utc = df3.utc.map(str) | |
sql.write_frame(df3, con=conn, name='readings', if_exists='append', flavor='mysql') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment