Data Science Jupyter Notebooks
11.8K subscribers
289 photos
43 videos
9 files
853 links
Explore the world of Data Science through Jupyter Notebooksβ€”insights, tutorials, and tools to boost your data journey. Code, analyze, and visualize smarter with every post.
Download Telegram
πŸ”₯ Trending Repository: pytorch

πŸ“ Description: Tensors and Dynamic neural networks in Python with strong GPU acceleration

πŸ”— Repository URL: https://github.com/pytorch/pytorch

🌐 Website: https://pytorch.org

πŸ“– Readme: https://github.com/pytorch/pytorch#readme

πŸ“Š Statistics:
🌟 Stars: 94.5K stars
πŸ‘€ Watchers: 1.8k
🍴 Forks: 25.8K forks

πŸ’» Programming Languages: Python - C++ - Cuda - C - Objective-C++ - CMake

🏷️ Related Topics:
#python #machine_learning #deep_learning #neural_network #gpu #numpy #autograd #tensor


==================================
🧠 By: https://t.me/DataScienceM
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "myDynamicElement"))
)

β€’ Get the page source after JavaScript has executed.
dynamic_html = driver.page_source

β€’ Close the browser window.
driver.quit()


VII. Common Tasks & Best Practices

β€’ Handle pagination by finding the "Next" link.
next_page_url = soup.find('a', text='Next')['href']

β€’ Save data to a CSV file.
import csv
with open('data.csv', 'w', newline='', encoding='utf-8') as f:
writer = csv.writer(f)
writer.writerow(['Title', 'Link'])
# writer.writerow([title, url]) in a loop

β€’ Save data to CSV using pandas.
import pandas as pd
df = pd.DataFrame(data, columns=['Title', 'Link'])
df.to_csv('data.csv', index=False)

β€’ Use a proxy with requests.
proxies = {'http': 'http://10.10.1.10:3128', 'https': 'http://10.10.1.10:1080'}
requests.get('http://example.com', proxies=proxies)

β€’ Pause between requests to be polite.
import time
time.sleep(2) # Pause for 2 seconds

β€’ Handle JSON data from an API.
json_response = requests.get('https://api.example.com/data').json()

β€’ Download a file (like an image).
img_url = 'http://example.com/image.jpg'
img_data = requests.get(img_url).content
with open('image.jpg', 'wb') as handler:
handler.write(img_data)

β€’ Parse a sitemap.xml to find all URLs.
# Get the sitemap.xml file and parse it like any other XML/HTML to extract <loc> tags.


VIII. Advanced Frameworks (Scrapy)

β€’ Create a Scrapy spider (conceptual command).
scrapy genspider example example.com

β€’ Define a parse method to process the response.
# In your spider class:
def parse(self, response):
# parsing logic here
pass

β€’ Extract data using Scrapy's CSS selectors.
titles = response.css('h1::text').getall()

β€’ Extract data using Scrapy's XPath selectors.
links = response.xpath('//a/@href').getall()

β€’ Yield a dictionary of scraped data.
yield {'title': response.css('title::text').get()}

β€’ Follow a link to parse the next page.
next_page = response.css('li.next a::attr(href)').get()
if next_page is not None:
yield response.follow(next_page, callback=self.parse)

β€’ Run a spider from the command line.
scrapy crawl example -o output.json

β€’ Pass arguments to a spider.
scrapy crawl example -a category=books

β€’ Create a Scrapy Item for structured data.
import scrapy
class ProductItem(scrapy.Item):
name = scrapy.Field()
price = scrapy.Field()

β€’ Use an Item Loader to populate Items.
from scrapy.loader import ItemLoader
loader = ItemLoader(item=ProductItem(), response=response)
loader.add_css('name', 'h1.product-name::text')


#Python #WebScraping #BeautifulSoup #Selenium #Requests

━━━━━━━━━━━━━━━
By: @DataScienceN ✨
❀3
πŸ”₯ Trending Repository: localstack

πŸ“ Description: πŸ’» A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline

πŸ”— Repository URL: https://github.com/localstack/localstack

🌐 Website: https://localstack.cloud

πŸ“– Readme: https://github.com/localstack/localstack#readme

πŸ“Š Statistics:
🌟 Stars: 61.1K stars
πŸ‘€ Watchers: 514
🍴 Forks: 4.3K forks

πŸ’» Programming Languages: Python - Shell - Makefile - ANTLR - JavaScript - Java

🏷️ Related Topics:
#python #testing #aws #cloud #continuous_integration #developer_tools #localstack


==================================
🧠 By: https://t.me/DataScienceM