How to use update_column method in pandera

Best Python code snippet using pandera_python

user_items.py

Source:user_items.py Github

copy

Full Screen

...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()...

Full Screen

Full Screen

ac_sheet.py

Source:ac_sheet.py Github

copy

Full Screen

...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))...

Full Screen

Full Screen

test_db.py

Source:test_db.py Github

copy

Full Screen

...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...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pandera automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful