A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| __author__ = 'leonmax' | |
| import asyncio | |
| from asyncio import (coroutine, subprocess) | |
| import sys | |
| import logging | |
| FORMAT = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
| logging.basicConfig(level=logging.INFO, format=FORMAT) |
A personal diary of DataFrame munging over the years.
Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)
| from django.db import connection | |
| from django.conf import settings | |
| cursor = connection.cursor() | |
| cursor.execute('SHOW TABLES') | |
| results=[] | |
| for row in cursor.fetchall(): | |
| results.append(row) | |
| for row in results: | |
| cursor.execute('ALTER TABLE %s CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' % (row[0])) |