Best Python code snippet using pandera_python
user_items.py
Source:user_items.py
...34 'company': 'ç产ä¼ä¸', 35 'factory_price': 'åºåä»·'}36#Update column names for user items37#åå·¥-MAåºå-å¨åº¦38BoxingItemHelper.update_column('compare_to_last_week', 'ç¯æ¯ä¸å¨')39BoxingItemHelper.update_column('inv', 'åºåé')40#åå·¥-MAä¸æ¸¸å¼å·¥-å¨åº¦41BoxingItemHelper.update_column('operation_rate', 'å¼å·¥ç')42BoxingItemHelper.update_column('operation_rate_last_week', 'ä¸å¨å¼å·¥ç')43BoxingItemHelper.update_column('change_compare_to_last_week', 'ç¯æ¯æ¶¨è·å¹
')44#åå·¥-MAä¸æ¸¸å¼å·¥-å¨åº¦45# BoxingItemHelper.update_column('operation_rate', 'å¼å·¥ç') #those are alread exists46# BoxingItemHelper.update_column('operation_rate_last_week', 'ä¸å¨å¼å·¥ç')47# BoxingItemHelper.update_column('compare_to_last_week', 'ç¯æ¯ä¸å¨')48BoxingItemHelper.update_column('operation_rate_last_year', 'å»å¹´åæ')49BoxingItemHelper.update_column('compare_year_on_year', 'ç¯æ¯ä¸å¨')50#åå·¥-MAä¸æ¸¸å¼å·¥-å¨åº¦ detail51BoxingItemHelper.update_column('region', 'åºå')52BoxingItemHelper.update_column('productivity', '产è½')53BoxingItemHelper.update_column('raw_material', 'ç产åæ')54#PPç²æä»·æ ¼55BoxingItemHelper.update_column('pp_powder_price_low', 'PPç²ä½ç«¯ä»·')56BoxingItemHelper.update_column('pp_powder_price_high', 'PPç²é«ç«¯ä»·')57BoxingItemHelper.update_column('propene_price_low', 'ä¸ç¯åä½ä½ç«¯ä»·')58BoxingItemHelper.update_column('propene_price_high', 'ä¸ç¯åä½é«ç«¯ä»·')59#åå·¥-PVCå¼å·¥-å¨åº¦60BoxingItemHelper.update_column('province', 'ç份')61BoxingItemHelper.update_column('producer', 'å家å称')62BoxingItemHelper.update_column('tech_process', 'å·¥èº')63BoxingItemHelper.update_column('brand', 'PVCçå·')64#åè65BoxingItemHelper.update_column('price_shandong', 'ä»·æ ¼ï¼å±±ä¸ï¼')66BoxingItemHelper.update_column('price_jiangsu', 'ä»·æ ¼ï¼æ±èï¼')67BoxingItemHelper.update_column('price_jingjin', 'ä»·æ ¼ï¼äº¬æ´¥ï¼')68#å¡æè69BoxingItemHelper.update_column('increase_daily', 'æ¥æ¶¨è·')70BoxingItemHelper.update_column('increase_to_last_week', 'è¾ä¸å¨åæ')71BoxingItemHelper.update_column('increase_to_last_month', 'è¾ä¸æåæ')72BoxingItemHelper.update_column('increase_to_last_year','è¾å»å¹´åæ')73#Oilchem74BoxingItemHelper.update_column('delta_rate','涨è·ç')75BoxingItemHelper.update_column('price_market','主æµä»·')76BoxingItemHelper.update_column('price_high','æé«ä»·')77# BoxingItemHelper.update_column('region','åºå')78BoxingItemHelper.update_column('price_low','æä½ä»·')79BoxingItemHelper.update_column('market','å¸åº')80#Company price81BoxingItemHelper.update_column('company_name', 'ä¼ä¸å称')82BoxingItemHelper.update_column('quote_price', 'ä¼ä¸æ¥ä»·')83#Base class of User Items84#To override some system settings85class BoxingUserSpiderItem(BoxingSpiderItem):86 @staticmethod87 def get_non_csv_columns():88 return ['filename', 'to_update', 'target_table', 'target_column', 'src_column', 'crawl_time', 'name']89################### For SampleSpider #####################################90class SampleItem(BoxingSpiderItem):91 name = scrapy.Field()92 unit = scrapy.Field()93 cur_price = scrapy.Field()94 week_price = scrapy.Field()95 month_price = scrapy.Field()96 delta = scrapy.Field()...
ac_sheet.py
Source:ac_sheet.py
...12TEMP_3_CELLS = 'J2:J289'13HUMIDITY_1_CELLS = 'D2:D289'14HUMIDITY_2_CELLS = 'H2:H289'15HUMIDITY_3_CELLS = 'L2:L289'16def update_column(sheet, cell_range, new_value):17 cells = sheet.range(cell_range)18 col_num = ord(cell_range[0])-6419 # print('cell_range = ', cell_range)20 # print('col_num = ', col_num)21 new_cell = gspread.Cell(289, col_num, value=new_value)22 for index in range(len(cells)):23 if index is not 0:24 cells[index - 1].value = cells[index].value25 # pprint(cells)26 cells[-1] = new_cell27 # pprint(cells)28 resp = sheet.update_cells(cells, value_input_option='USER_ENTERED')29 # resp = sheet.update_cells(cells, value_input_option='RAW')30 # resp = sheet.update_cells(cells)31 print(resp)32if not DUMMY_MODE:33 sensor_22 = Adafruit_DHT.DHT2234 sensor_11 = Adafruit_DHT.DHT1135vent_pin = 436room_pin = 1737back_pin = 2238if not DUMMY_MODE:39 vent_humidity, vent_temperature = Adafruit_DHT.read_retry(sensor_22, vent_pin)40 room_humidity, room_temperature = Adafruit_DHT.read_retry(sensor_11, room_pin)41 back_humidity, back_temperature = Adafruit_DHT.read_retry(sensor_11, back_pin)42else:43 vent_temperature = 11.044 vent_humidity = 12.045 room_temperature = 13.046 room_humidity = 14.047 back_temperature = None48 back_humidity = None49if vent_temperature is not None:50 vent_temperature = vent_temperature * 9 / 5 + 3251if room_temperature is not None:52 room_temperature = room_temperature * 9 / 5 + 3253if back_temperature is not None:54 back_temperature = back_temperature * 9 / 5 + 3255if vent_humidity is not None and vent_temperature is not None:56 print('Vent: Temp={0:0.1f}*F Humidity={1:0.1f}%'.format(vent_temperature, vent_humidity))57else:58 print('Failed to get vent reading')59 vent_humidity = ''60 vent_temperature = ''61if room_humidity is not None and room_temperature is not None:62 print('Room: Temp={0:0.1f}*F Humidity={1:0.1f}%'.format(room_temperature, room_humidity))63else:64 print('Failed to get room reading')65 room_humidity = ''66 room_temperature = ''67if back_humidity is not None and back_humidity is not None:68 print('Back: Temp={0:0.1f}*F Humidity={1:0.1f}%'.format(back_temperature, back_humidity))69else:70 print('Failed to get back reading')71 back_humidity = ''72 back_temperature = ''73scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']74creds = ServiceAccountCredentials.from_json_keyfile_name('/home/pi/ac_log/ac logger-xxxxxxxxxxxx.json', scope)75client = gspread.authorize(creds)76spreadsheet = client.open("ac_performance").sheet177update_column(spreadsheet, TIME_CELLS, str(datetime.utcnow()))78update_column(spreadsheet, TEMP_1_CELLS, str(vent_temperature))79update_column(spreadsheet, TEMP_2_CELLS, str(room_temperature))80update_column(spreadsheet, TEMP_3_CELLS, str(back_temperature))81update_column(spreadsheet, HUMIDITY_1_CELLS, str(vent_humidity))82update_column(spreadsheet, HUMIDITY_2_CELLS, str(room_humidity))...
test_db.py
Source:test_db.py
...20 g1 = {"id": 1, "name": "Among Us", "platform": "android", "publisher": "Innersloth LLC", "release_date": "2018-07-25", "genre": "action", "game_engine": "Unity"}21 game = db.save(models.Game(**g1), test_conn, test_cursor)22 23 game.game_engine = 'something_else'24 db.update_column(game, 'game_engine', test_conn, test_cursor)25 game.genre = 'Space Wars'26 db.update_column(game, 'genre', test_conn, test_cursor)27 28 game_update = db.find(models.Game, game.id, test_cursor)29 assert game_update.game_engine == 'something_else'30 assert game_update.genre == 'Space Wars'31def test_update_column_for_earnings_table(test_conn):32 test_cursor = test_conn.cursor()33 e1 = {"id": 1, "game_id": 1, "price": 0.0, "inapp": True, "shows_ads": False, "revenue": 2000000, "downloads": 29000000}34 earnings = db.save(models.Earnings(**e1), test_conn, test_cursor)35 36 earnings.downloads = 2300000037 db.update_column(earnings, 'downloads', test_conn, test_cursor)38 earnings.revenue = 139 db.update_column(earnings, 'revenue', test_conn, test_cursor)40 41 earnings_update = db.find(models.Earnings, earnings.id, test_cursor)42 assert earnings_update.downloads == 23000000...
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!!