Posts

RESTful APIs with Flask in PyCharm

Image
  Building RESTful APIs with Flask in PyCharm Building RESTful APIs with Flask in Py-Charm involves setting up a Flask project, writing API endpoints, and running the application.  Installing packages Once your virtualenv is ready, click the “Install” button to begin installing packages. We’ll be installing three packages for our project: Flask  (install either by pycharms STTINGS-----PYTHON INTERPRETOR (+)) Flask-Restless  (for building the RESTful API) Flask-SQLAlchemy  (for connecting to our database) || OR  MySQLdb In Pycharms (Main.py):write below code here change parameters as per your database: import flask from flask import Flask, json, request, jsonify from flask_mysqldb import MySQL, MySQLdb # pip install flask-mysqldb https://github.com/alexferl/flask-mysqldb app = Flask(__name__) app.secret_key = "2021" app.config[ 'MYSQL_HOST' ] = 'localhost' app.config[ 'MYSQL_USER' ] = 'root' app.config[ 'MYSQL_PASSWORD' ] = ''...

Python Pandas As Json

Image
 Python Pandas As Json Pandas allows us to analyze big data and make conclusions based on statistical theories. Pandas can clean messy data sets, and make them readable and relevant. Pandas gives you answers about the data. Like: Is there a correlation between two or more columns? What is average value? Max value? Min value? Pandas are also able to delete rows that are not relevant, or contains wrong values, like empty or NULL values. This is called  cleaning  the data. Installation of Pandas If you have Python and PIP already installed on a system, then installation of Pandas is very easy. (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\RCF>cd.. C:\Users>cd.. C:\>cd Python3.9.1 C:\Python3.9.1>cd Scripts C:\Python3.9.1\Scripts> pip install pandas Collecting pandas   Downloading pandas-1.2.0-cp39-cp39-win_amd64.whl (9.3 MB)      |████████████████████████████████| 9.3 MB 18 kB/s Collecting python-dateutil...

Python MySQL with WAMP

Image
  Install MySQL Driver Python is a high-level, general-purpose, and very popular programming language. Basically, it was designed with an emphasis on code readability, and programmers can express their concepts in fewer lines of code. We can also use Python with SQL. In this article, we will learn how to connect SQL with Python using the ‘MySQL Connector Python module. The diagram given below illustrates how a connection request is sent to MySQL connector Python, how it gets accepted from the database and how the cursor is executed with result data. Move to ur Python Scripts location Microsoft Windows [Version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved. C:\Users\RCF>cd.. C:\Users>cd.. C:\>cd Python3.9.1 C:\Python3.9.1>cd Scripts C:\Python3.9.1\Scripts>python -m pip install mysql-connector-python Collecting mysql-connector-python   Downloading mysql_connector_python-8.0.22-py2.py3-none-any.whl (374 kB)      |███████...

Python – Color Detection using Pandas & OpenCV

Image
  Python – Color Detection using Pandas & OpenCV What is Color Detection? Color detection is the process of detecting the name of any color. Simple isn’t it? Well, for humans this is an extremely easy task but for computers, it is not straightforward. Human eyes and brains work together to translate light into color. Light receptors that are present in our eyes transmit the signal to the brain. Our brain then recognizes the color. Since childhood, we have mapped certain lights with their color names. We will be using the somewhat same strategy to detect color names. Prerequisites Before starting with this Python project with source code, you should be familiar with the computer vision library of Python that is  OpenCV  and  Pandas . OpenCV, Pandas, and numpy are the Python packages that are necessary for this project in Python. To install them, simply run this pip command in your terminal: pip install opencv-python numpy pandas Run Python File The beginner Python...

Python Dictionaries

Image
 Python Dictionaries What is a Dictionary? A dictionary in Python is an unordered collection of key-value pairs. It's like a real-world dictionary where you look up a word (key) to find its definition (value). What are the features of the dictionary in Python? In Python, a dictionary is an unordered collection of items that stores data in key-value pairs. Here are the key features of dictionaries: Key-Value Pairs : Each item in a dictionary consists of a key and a corresponding value. Keys must be unique and immutable (e.g., strings, numbers, tuples), while values can be of any data type. Unordered : Dictionaries do not maintain the order of items. However, as of Python 3.7, dictionaries preserve the insertion order of keys. Mutable : Dictionaries can be modified after creation. You can add, remove, or change items. Dynamic Size : The size of a dictionary can grow or shrink as items are added or removed. Fast Lookups : Dictionaries provide average-case time complexity of O(1) for l...

Tuple in Python

Image
 Understanding Tuples in Python In Python, a tuple is an immutable, ordered collection of elements. It is similar to a list, but unlike lists, tuples cannot be modified once they are created. This makes tuples a good choice for storing data that should not change throughout the program. Tuples are often used for heterogeneous data (different types of data) or when you want to ensure that the data remains constant. Key Characteristics of Tuples Immutable : Once defined, the elements cannot be altered, added, or removed. Ordered : Tuples maintain the order of their elements. Allows Duplicates : Elements can repeat within a tuple. Heterogeneous : Tuples can hold items of different data types. How to Create a Tuple You can create a tuple by enclosing elements in parentheses () separated by commas. # Creating tuples empty_tuple = ()               # An empty tuple single_element_tuple = (42,)   # A single-element tuple (comma is require...

Sets in Python

Image
 Sets in Python Sets in Python are unordered collections of unique elements in Python. They are similar to lists but do not allow duplicate elements. Sets are defined using curly braces {} or the set() constructor. Key Characteristics: Unordered: Elements in a set do not have a specific order. Unique Elements: Sets cannot contain duplicate elements. Mutable: Sets can be modified by adding or removing elements. Iterable: You can iterate over the elements of a set using a loop. Creating Sets: # Creating a set using curly braces my_set = {1, 2, 3, 4, 5} # Creating a set using the set() constructor my_set = set([1, 2, 3, 4, 5]) Creating a set The set can be created by enclosing the comma-separated immutable items with the curly braces {}. Python also provides the set() method, which can be used to create the set by the passed sequence. Example 1: Using curly braces Days = { "Monday" ,  "Tuesday" ,  "Wednesday" ,  "Thursday" ,  "Friday...