Found 10784 Articles for Python

Data visualization with different Charts in Python?

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

233 Views

Python provides various easy to use libraries for data visualization. Good thing is that these libraries works with small or large datasets.Some of the most commonly used python libraries for data visualizations are −MatplotlibPandasPlotlySeabornBelow we are going to plot different types of visualization chart for one fixed data to better analyse that data.We are going to analyze below data set to visualize through different charts −Country or AreaYear(s)VariantValueIndia2019Medium1368737.513India2019High1378419.072India2019Low1359043.965India2019Constant fertility1373707.838India2019Instant replacement1366687.871India2019Zero migration1370868.782India2019Constant mortality1366282.778India2019No change1371221.64India2019Momentum1367400.614Basic Plot Let's create some basic plots: Line plots, scatter plots and histogramsLine PlotsLine graphs are plots where a line is drawn to indicate a relationship between a particular ... Read More

Data Analysis and Visualization in Python?

Nitya Raut
Updated on 30-Jul-2019 22:30:25

1K+ Views

Python provides numerous libraries for data analysis and visualization mainly numpy, pandas, matplotlib, seaborn etc. In this section, we are going to discuss pandas library for data analysis and visualization which is an open source library built on top of numpy.It allows us to do fast analysis and data cleaning and preparation.Pandas also provides numerous built-in visualization feautures which we are going to see below.InstallationTo install pandas, run the below command in your terminal −pipinstall pandasOrwe have anaconda, you can usecondainstall pandasPandas-DataFramesData framesa re the main tools when we are working with pandas.code −import numpy as np import pandas as ... Read More

List of Keywords in Python Programming

Anvi Jain
Updated on 11-Aug-2022 11:37:47

1K+ Views

Keywords in Python are reserved words. You cannot use them as variable name, function name, class name, etc. Following are the Keywords in Python − Keywords in Python FALSE await else import pass None break except in raise TRUE class finally is return and continue for lambda try as def from nonlocal while assert del global not with async ... Read More

Convert between binary and ASCII using Python (binascii)

Smita Kapse
Updated on 30-Jul-2019 22:30:25

787 Views

The binascii module enables conversion between binary and various ASCII encoded binary representations. The binascii module contains low-level functions written in C for greater speed. They are used by the higher-level modules such as uu, base64 or binhex modules.The binascii module defines the following functions. These function are named as a2b_* or b2a_*binascii.a2b_uu(string): Convert a single line of uuencoded data back to binary and return the binary data. Lines normally contain 45 (binary) bytes, except for the last line. Line data may be followed by white space.binascii.b2a_uu(data): Convert binary data to a line of ASCII characters, the return value is the converted ... Read More

Encode and decode binhex4 files using Python (binhex)

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

394 Views

The binhex module encodes and decodes files in binhex4 format. This format is used in the representation of Macintosh files in ASCII. Only the data fork is handled.The binhex module defines the following functions −binhex.binhex(input, output): Convert a binary file with filename input to binhex file output. The output parameter can either be a filename or a file-like object (any object supporting a write() and close() method).binhex.hexbin(input, output): Decode a binhex file input. input may be a filename or a file-like object supporting read() and close() methods. The resulting file is written to a file named output unless the argument is None ... Read More

Python Context Variables

Smita Kapse
Updated on 30-Jul-2019 22:30:25

1K+ Views

Context variable can have different values depending on its context. Unlike Thread-Local Storage where each execution thread may have a different value for a variable, a context variable may be several contexts in one execution thread. This is useful in keeping track of variables in concurrent asynchronous tasks.The ContextVar class is used to declare and work with Context Variables.import contextvars name = contextvars.ContextVar("name", default = 'Hello')The optional default parameter is returned by ContextVar.get() when no value for the variable is found in the current context.name: The name of the variable. This is a read-only property.Following methods are defined in ContextVar ... Read More

Python Interfaces to Unix databases (dbm)

Anvi Jain
Updated on 30-Jul-2019 22:30:25

182 Views

The dbm package in Python's built-in library provides a dictionary like an interface DBM style databases. The dbm library is a simple database engine, written by Ken Thompson. DBM stands for DataBase Manager, used by UNIX operating system, the library stores arbitrary data by use of a single key (a primary key) in fixed-size buckets and uses hashing techniques to enable fast retrieval of the data by key.There are following modules in dbm package −The dbm.ndbm module provides an interface to the Unix “(n)dbm” library. Dbm objects behave like dictionaries, with keys and values should be stored as bytes. The ... Read More

Generate and parse Mac OS X .plist files using Python (plistlib)

Smita Kapse
Updated on 30-Jul-2019 22:30:25

2K+ Views

Files with '.plist' the extension is used by Mac OS X applications to store application properties. The plislib module provides an interface to read/write operations of these property list files.The plist file format serializes basic object types, like dictionaries, lists, numbers, and strings. Usually, the top level object is a dictionary. To write out and to parse a plist file, use the dump() and load() functions. Serialized byte strings are handled by use dumps() and loads() functions. Values can be strings, integers, floats, booleans, tuples, lists, dictionaries (but only with string keys).This module defines the following functions −load()Read a plist ... Read More

Inspect live objects in Python

Nishtha Thakur
Updated on 30-Jul-2019 22:30:25

572 Views

Functions in this module provide usefule information about live objects such as modules, classes, methods, functions, code objects etc. These functions perform type checking, retrieve source code, inspect classes and functions, and examine the interpreter stack.getmembers()− This function returns all the members of an object in a list of name, value pairs sorted by name. If the optional predicate is supplied, only members for which the predicate returns a true value are included. getmodulename() −This function returns the name of the module named by the file path, without including the names of enclosing packagesWe shall be using following script for ... Read More

Filtering Images based on size attributes in Python?

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

207 Views

Python provides multiple libraries for image processing including Pillow, Python Imaging library, scikit-image or OpenCV.We are going to use Pillow library for image processing here as it offers multiple standard procedures for image manipulation and supports the range of image file formats such as jpeg, png, gif, tiff, bmp and others.Pillow library is built on top of Python Imaging Library(PIL) and provides more features than its parent library(PIL).InstallationWe can install pillow using pip, so just type following in the command terminal −$ pip install pillowBasic operation on a pillowLet’s some basic operation on images using pillow library.from PIL import Image ... Read More

Advertisements