In work, we use oracle sql database, in times on times(rarely, but happens), the database is feed with data in wrong format, like this:
Sales | Price |
---|---|
s1 | 10.00 |
s2 | 10,00 |
s3 | 10 |
All lines has same price, but in different formats, how can i standardize price column in same format using python?
Follow the code used:
import pandas as pd
import cx_Oracle
import numpy as np
cx_Oracle.init_oracle_client(path to oracle client)
def connect(user, password, host):
connection = cx_Oracle.connect(user=user, password = password, dsn = host)
cursor = connection.cursor()
return cursor
def sql(query,cursor):
cursor.execute(query)
result = cursor.fetchall()
cols = [i[0] for i in cursor.description]
df = pd.DataFrame(result, columns=[cols])
return df
query = """
querie
"""
df = sql(query,cursor)
df.columns = df.columns.get_level_values(0)