Skip to content

Commit 90d3915

Browse files
committed
round
1 parent 88a736c commit 90d3915

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

pandas_to_sql/engine/columns/numeric_columns.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ def __neg__(self):
6464
return type(self)(sql_string=f'(-({value_to_sql_string(self)}))')
6565

6666

67+
def round_(self):
68+
return FloatColumn(sql_string=f'(ROUND({value_to_sql_string(self)}))')
69+
70+
6771

6872
add_comparison_operators_to_class(FloatColumn)
6973
FloatColumn.__add__ = __add__
@@ -78,6 +82,7 @@ def __neg__(self):
7882
FloatColumn.__rtruediv__ = __rtruediv__
7983
FloatColumn.__abs__ = __abs__
8084
FloatColumn.__neg__ = __neg__
85+
FloatColumn.round = round_
8186

8287

8388
add_comparison_operators_to_class(IntColumn)
@@ -93,4 +98,4 @@ def __neg__(self):
9398
IntColumn.__rtruediv__ = __rtruediv__
9499
IntColumn.__abs__ = __abs__
95100
IntColumn.__neg__ = __neg__
96-
101+
IntColumn.round = round_

pandas_to_sql/testing/tests/test_operations_numeric.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,9 @@ def test_floordiv():
7272
def test_rfloordiv():
7373
df = pytest.df1
7474
df['new_value'] = 1 // df.random_float
75-
assert_(df)
75+
assert_(df)
76+
77+
def test_round():
78+
df = pytest.df1
79+
df['new_value'] = df.random_float.round()
80+
assert_(df)

0 commit comments

Comments
 (0)