great-tables icon indicating copy to clipboard operation
great-tables copied to clipboard

GT(sp500_mini) TypeError: 'module' object is not callable

Open Ambier opened this issue 5 months ago • 1 comments

按照示例去操作会报错, 错误如下: GT(sp500_mini) TypeError: 'module' object is not callable

`from great_tables import GT from great_tables.data import sp500

Define the start and end dates for the data range

start_date = "2010-06-07" end_date = "2010-06-14"

Filter sp500 using Pandas to dates between start_date and end_date

sp500_mini = sp500[(sp500["date"] >= start_date) & (sp500["date"] <= end_date)]

Create a gt table based on the sp500_mini table data

( GT(sp500_mini) .tab_header(title="S&P 500", subtitle=f"{start_date} to {end_date}") .fmt_currency(columns=["open", "high", "low", "close"]) .fmt_date(columns="date", date_style="wd_m_day_year") .fmt_number(columns="volume", compact=True) .cols_hide(columns="adj_close") )`

建议把示例来修改,改成: `from great_tables import GT from great_tables.data import sp500

Define the start and end dates for the data range

start_date = "2010-06-07" end_date = "2010-06-14"

Filter sp500 using Pandas to dates between start_date and end_date

sp500_mini = sp500[(sp500["date"] >= start_date) & (sp500["date"] <= end_date)]

Create a gt table based on the sp500_mini table data

( GT.GT(sp500_mini) .tab_header(title="S&P 500", subtitle=f"{start_date} to {end_date}") .fmt_currency(columns=["open", "high", "low", "close"]) .fmt_date(columns="date", date_style="wd_m_day_year") .fmt_number(columns="volume", compact=True) .cols_hide(columns="adj_close") .show() )`

Ambier avatar Jun 19 '25 01:06 Ambier

I'm not sure what's going wrong—the example runs fine on my machine:

from great_tables import GT
from great_tables.data import sp500

# Define the start and end dates for the data range
start_date = "2010-06-07"
end_date = "2010-06-14"

# Filter sp500 using Pandas to dates between `start_date` and `end_date`
sp500_mini = sp500[(sp500["date"] >= start_date) & (sp500["date"] <= end_date)]

# Create a display table based on the `sp500_mini` table data
(
    GT(sp500_mini)
    .tab_header(title="S&P 500", subtitle=f"{start_date} to {end_date}")
    .fmt_currency(columns=["open", "high", "low", "close"])
    .fmt_date(columns="date", date_style="wd_m_day_year")
    .fmt_number(columns="volume", compact=True)
    .cols_hide(columns="adj_close")
)

jrycw avatar Jun 19 '25 04:06 jrycw