MCPcopy
hub / github.com/pandas-dev/pandas / setup

Method setup

asv_bench/benchmarks/io/sql.py:102–121  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

100
101class ReadSQLTable:
102 def setup(self):
103 N = 10000
104 self.table_name = "test"
105 self.con = create_engine("sqlite:///:memory:")
106 self.df = DataFrame(
107 {
108 "float": np.random.randn(N),
109 "float_with_nan": np.random.randn(N),
110 "string": ["foo"] * N,
111 "bool": [True] * N,
112 "int": np.random.randint(0, N, size=N),
113 "datetime": date_range("2000-01-01", periods=N, freq="s"),
114 },
115 index=Index([f"i-{i}" for i in range(N)], dtype=object),
116 )
117 self.df.iloc[1000:3000, 1] = np.nan
118 self.df["date"] = self.df["datetime"].dt.date
119 self.df["time"] = self.df["datetime"].dt.time
120 self.df["datetime_string"] = self.df["datetime"].astype(str)
121 self.df.to_sql(self.table_name, self.con, if_exists="replace")
122
123 def time_read_sql_table_all(self):
124 read_sql_table(self.table_name, self.con)

Callers

nothing calls this directly

Calls 5

DataFrameClass · 0.90
date_rangeFunction · 0.90
IndexClass · 0.90
astypeMethod · 0.45
to_sqlMethod · 0.45

Tested by

no test coverage detected