Skip to content

Commit

Permalink
remove comment and move imports
Browse files Browse the repository at this point in the history
  • Loading branch information
gladysteh99 committed Sep 4, 2024
1 parent 4a2412a commit 601cf38
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
6 changes: 2 additions & 4 deletions locopy/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"""Database Module."""

import time
import pandas
import polars

from locopy.errors import CredentialsError, DBError
from locopy.logger import INFO, get_logger
Expand Down Expand Up @@ -223,12 +225,8 @@ def to_dataframe(self, df_type="pandas", size=None):
return None

if df_type == "pandas":
import pandas

return pandas.DataFrame(fetched, columns=columns)
elif df_type == "polars":
import polars

return polars.DataFrame(fetched, schema=columns, orient="row")

def to_dict(self):
Expand Down
8 changes: 4 additions & 4 deletions locopy/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
import os
from pathlib import Path

import pandas as pd
import polars as pl
import polars.selectors as cs

from locopy.database import Database
from locopy.errors import DBError, S3CredentialsError
from locopy.logger import INFO, get_logger
Expand Down Expand Up @@ -567,10 +571,6 @@ def insert_dataframe_to_table(
"""
import pandas as pd
import polars as pl
import polars.selectors as cs

if columns:
try:
dataframe = dataframe[columns]
Expand Down
8 changes: 3 additions & 5 deletions locopy/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"""

import os
import pandas as pd
import polars as pl
import polars.selectors as cs
from pathlib import PurePath

from locopy.database import Database
Expand Down Expand Up @@ -423,9 +426,6 @@ def insert_dataframe_to_table(
metadata: dictionary, optional
If metadata==None, it will be generated based on data
"""
import pandas as pd
import polars as pl
import polars.selectors as cs

if columns:
try:
Expand Down Expand Up @@ -511,8 +511,6 @@ def to_dataframe(self, df_type="pandas", size=None):
if df_type == "pandas":
return self.cursor.fetch_pandas_all()
elif df_type == "polars":
import polars as pl

return pl.from_arrow(self.cursor.fetch_arrow_all())
else:
return super().to_dataframe(df_type=df_type, size=size)
2 changes: 0 additions & 2 deletions locopy/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import sys
import threading
from collections import OrderedDict

# https://docs.python.org/3/library/functools.html#functools.singledispatch
from functools import singledispatch
from itertools import cycle
from typing import Union
Expand Down

0 comments on commit 601cf38

Please sign in to comment.