Posts

Showing posts with the label python

Excel, SQL, and Pandas: One-to-One Cheat Sheet for Everyday Data Tasks

Image
A compact, side-by-side reference that maps common data tasks across  Excel ,  SQL , and  Python (Pandas) . Copy/paste the snippets and adapt table/column names to your data. A lot of us think in  Excel , work with data stored in  SQL  databases, and script repeatable workflows in  Python (Pandas) . This cheat sheet lines those worlds up so you can translate muscle memory across tools: if you know how to do it in one, you’ll see the equivalent in the others. It focuses on everyday tasks—loading data, filtering, selecting, sorting, aggregating, joining, creating new columns, handling missing values, exporting, and plotting—using short, copy-pasteable patterns. What's included Loading data, selecting columns, filtering, sorting Grouping/aggregations, joins, computed columns Missing data handling, exporting, and quick charts Who this is for Analysts, engineers, and anyone who bounces between CSVs, databases, and notebooks. If you know one of these tools, ...

SSL: CERTIFICATE_VERIFY_FAILED with Python2.7/3

Image
To enhance flexibility and address specific use cases, modifications will be made to the ssl module instead of consistently relying on  ssl.create_default_context . The updated approach involves checking the  PYTHONHTTPSVERIFY  environment variable upon the module’s initial import in a Python process. The  ssl._create_default_https_context  function will then be configured as follows: If the environment variable is present and set to ‘0’,  ssl._create_default_https_context  will be an alias for ssl._create_unverified_context. Otherwise,  ssl._create_default_https_context  will be an alias for  ssl.create_default_context , adhering to the usual behavior. Here is an example implementation: import os import sys import ssl _https_verify_envvar = 'PYTHONHTTPSVERIFY' def _get_https_context_factory () : if not sys.flags.ignore_environment: config_setting = os.environ.get(_https_verify_envvar) if config_setting == ...

Python RegEx: практическое применение регулярок

Image
Рассмотрим регулярные выражения в Python, начиная синтаксисом и заканчивая примерами использования. Основы регулярных выражений Регулярные выражения в Python Задачи 1. Основы регулярных выражений Регулярками называются шаблоны, которые используются для поиска соответствующего фрагмента текста и сопоставления символов. Грубо говоря, у нас есть input-поле, в которое должен вводиться email-адрес. Но пока мы не зададим проверку валидности введённого email-адреса, в этой строке может оказаться совершенно любой набор символов, а нам это не нужно. Чтобы выявить ошибку при вводе некорректного адреса электронной почты, можно использовать следующее регулярное выражение: r '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$' По сути, наш шаблон — это набор символов, который проверяет строку на соответствие заданному правилу. Давайте разберёмся, как это работает. Синтаксис RegEx Синтаксис у регулярок необычный. Символы могут быть как буквами или цифрами, так и метасимволами, которые зада...