forked from Sinaptik-AI/pandas-ai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_df_info.py
32 lines (27 loc) · 1.02 KB
/
test_df_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest
import pandas as pd
import polars as pl
from pandasai.helpers.df_info import df_type
class TestDfInfo(unittest.TestCase):
def setUp(self):
self.pd_df = pd.DataFrame(
{"A": [1, 2, 3], "B": ["foo", "bar", "baz"], "C": [1.0, 2.0, 3.0]}
)
self.pl_df = None
if "pl" in globals():
self.pl_df = pl.DataFrame(
{"A": [1, 2, 3], "B": ["foo", "bar", "baz"], "C": [1.0, 2.0, 3.0]}
)
def test_df_type_pandas(self):
actual_output = df_type(self.pd_df)
expected_output = "pandas"
self.assertEqual(actual_output, expected_output)
def test_df_type_polars(self):
if self.pl_df is not None:
actual_output = df_type(self.pl_df)
expected_output = "polars"
self.assertEqual(actual_output, expected_output)
def test_df_type_none(self):
actual_output = df_type("not a dataframe")
expected_output = None
self.assertEqual(actual_output, expected_output)