Best Python code snippet using pandera_python
db.py
Source: db.py
...213 self._process_insert(value, key)214 except sqlite3.IntegrityError, e:215 raise TypeError("A row with the given ID already exists. Either edit the existing one, or append a new row using append().")216 217 def _set_column_names(self, names):218 self._column_names = names219 220 def _retrieve_column_names(self):221 cur = self.db.query("SELECT * FROM %s WHERE 0" % self.table) # Not SQLi-safe!222 self._set_column_names([x[0] for x in cur.description])223 224 def __getattr__(self, name):225 if name == "columns":226 try:227 return self._column_names228 except AttributeError, e:229 self._retrieve_column_names()230 return self._column_names231 else:232 raise AttributeError("No such attribute exists")233 234 def append(self, value):235 value._table = self.table236 return self._process_insert(value)237 238class DatabaseTable(Table):239 def __init__(self, database, table_name):240 Table.__init__(self, database, table_name)241 self._cache = {}242 243 def _process_insert(self, value, key=None):244 rowid = Table._process_insert(self, value, key)245 self._cache[rowid] = value246 return rowid247 248 def __getitem__(self, key):249 try:250 return self._cache[key]251 except KeyError, e:252 result = self.db.query("SELECT * FROM %s WHERE `Id` = ?" % self.table, params=(key,))253 self._set_column_names([x[0] for x in result.description])254 255 if result is None:256 raise KeyError("No row with that ID was found in the table.")257 else:258 row = result.fetchone()259 row._db = self.db260 row._table = self.table261 row._type = "database"262 self._cache[key] = row263 return row264 265 def __setitem__(self, key, value):266 self._try_set(key, value, self._cache)267 268 def purge(self):269 self._cache = {}270class MemoryTable(Table):271 def __init__(self, database, table_name):272 Table.__init__(self, database, table_name)273 self.data = {}274 self._retrieve_data()275 276 def _retrieve_data(self):277 result = self.db.query("SELECT * FROM %s" % self.table) # Not SQLi-safe!278 self._set_column_names([x[0] for x in result.description])279 280 for row in result:281 row._db = self.db282 row._table = self.table283 row._type = "memory"284 self.data[row['Id']] = row285 286 def _process_insert(self, value, key=None):287 rowid = Table._process_insert(self, value, key)288 self.data[rowid] = value289 self.data[rowid]._db = self.db290 self.data[rowid]._table = self.table291 self.data[rowid]._type = "memory"292 return rowid...
data_structures.py
Source: data_structures.py
...42 column_names: List[str] = field(init=False)43 def __post_init__(self):44 self._same_size_columns()45 self.index = self._set_index()46 self.column_names = self._set_column_names()47 self._check_column_name_collision()48 def __dict__(self):49 return {col.name:col.values for col in self.columns}50 def _set_column_names(self) -> List[str]:51 return [col.name for col in self.columns]52 def _same_size_columns(self):53 lengths = [col.length for col in self.columns]54 if max(lengths) != min(lengths):55 raise ValueError("Column sizes are not the same.")56 def _set_index(self):57 return list(range(self.columns[0].length))58 def _check_column_name_collision(self):59 col_names = [col.name for col in self.columns]60 if len(set(col_names)) != len(col_names):61 raise ValueError(f"You cannot have repeated column names, this will create collisions")62 def get_row(self, index_value: int) -> Dict:63 return {col.name:col.values[index_value] for col in self.columns}64 def get_column(self, column_name: str) -> Column:...
google_drive.py
Source: google_drive.py
...37 return file_list38 else:39 raise ValueError("No files returned from server. Make sure, folder id is correct and folder is shared.")40@R.curry41def _set_column_names(df: pd.DataFrame) -> pd.DataFrame:...
Check out the latest blogs from LambdaTest on this topic:
I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.
When I started writing tests with Cypress, I was always going to use the user interface to interact and change the application’s state when running tests.
Pair testing can help you complete your testing tasks faster and with higher quality. But who can do pair testing, and when should it be done? And what form of pair testing is best for your circumstance? Check out this blog for more information on how to conduct pair testing to optimize its benefits.
People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.
Have you ever visited a website that only has plain text and images? Most probably, no. It’s because such websites do not exist now. But there was a time when websites only had plain text and images with almost no styling. For the longest time, websites did not focus on user experience. For instance, this is how eBay’s homepage looked in 1999.
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!