Skip to content

Instantly share code, notes, and snippets.

# Set new-column-uca5 in StudentsPerformance_csv to =(math score+reading score+writing score)/3
StudentsPerformance_csv['average'] = (StudentsPerformance_csv['math score']+StudentsPerformance_csv['reading score']+StudentsPerformance_csv['writing score'])/3
# Added column new-column-uca5 to StudentsPerformance_csv
StudentsPerformance_csv.insert(8, 'new-column-uca5', 0)
# Renamed new-column-uca5 to average in StudentsPerformance_csv
StudentsPerformance_csv.rename(columns={'new-column-uca5': 'average'}, inplace=True)
import scrapy
class WorldometersSpider(scrapy.Spider):
name = 'worldometers'
allowed_domains = ['www.worldometers.info']
start_urls = ['https://www.worldometers.info/world-population/population-by-country/']
def parse(self, response):
pass
import scrapy
class WorldometersSpider(scrapy.Spider):
name = 'worldometers'
allowed_domains = ['www.worldometers.info']
start_urls = ['https://www.worldometers.info/world-population/population-by-country/']
def parse(self, response):
# Getting all the rows of the table
import scrapy
class WorldometersSpider(scrapy.Spider):
name = 'worldometers'
allowed_domains = ['www.worldometers.info']
start_urls = ['https://www.worldometers.info/world-population/population-by-country/']
def parse(self, response):
# Getting all the rows of the table
# Get the transcript
element = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPath, '//div[@class="full-script"]')))
from bs4 import BeautifulSoup
import requests
root = 'https://subslikescript.com'
website = f'{root}/movies'
result = requests.get(website)
content = result.text
soup = BeautifulSoup(content, 'lxml')
box = soup.find('article', class_='main-article')
import pandas as pd
import openpyxl
from openpyxl import load_workbook
from openpyxl.styles import Font
from openpyxl.chart import BarChart, Reference
import string
def automate_excel(file_name):
"""The file name should have the following structure: sales_month.xlsx"""
# read excel file
#select only upcoming matches box
box = driver.find_element_by_xpath('//div[contains(@testid, "Program_SELECTION")]')
#scroll down to the bottom to load upcoming matches
driver.execute_script("window.scrollTo(0, document.body.scrollHeight)")
time.sleep(3) #add implicit if necessary