Posts

Can we replace pandas library with datatable?

Pandas:  Pandas is an open-source library. It provides various data structures and operations for manipulating data and time series.  1. Time taken to readCSV using Pandas and Datatable : import pandas as pd import time file = 'annual-enterprise-survey.csv' start_Time=time.time() df = pd.read_csv(file) end_Time=time.time() # At the end of script execution_time=(end_Time-start_Time) print("Execution time for pandas",execution_time*60) Output: Execution time for pandas 4.621939659118652 import datatable as dt import time start_Time1 =time.time() dt_df = dt.fread(file) dt_df = dt_df.to_pandas() end_Time1=time.time() # At the end of script execution_time1=(end_Time1-start_Time1) print("Execution time for datatable",execution_time1*60) Output: Execution time for datatable 3.1781816482543945 2. Time taken to save CSV using Pandas and Datatable : import pandas as pd import time file = 'annual-enterprise-survey.csv' start_Time=time.time() df = pd.read_csv(fi...

Spelling correction using TextBlob in python.

What is TextBlob? TextBlob is python library for processing textual data. It is built on the top of NLTK module. How to install TextBlob?     1. Using pip:         pip install textblob     2. Using conda:         conda install -c conda-forge textblob Some terms that will be frequently used are : · Corpus – Body of text, singular. · Lexicon – Words and their meanings. · Token – Each “entity” that is a part of whatever was split up based on rules. For examples, each word is a token when a sentence is “tokenized” into words. Each sentence can also be a token, if you tokenized the sentences out of a paragraph. Textblob(text,tokenizer= None, np_extractor=None,pos_tagger=None,analyzer=None,classifier=None):  A general text block, meant for larger bodies of text.     Parameters:      text: string     tokenzier:  (optional) A tokenizer instance. If None, defaults to WordTokenizer().   ...

Second Library: Matplotlib

Image
Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. To install matplotlib: Install using pip:              pip install matplotlib Install using conda:        conda install matplotlib Matplotlib consists of the following submodules:  matplotlib.pyplot matplotlib.animation matplotlib.artist matplotlib.image matplotlib.text matplotlib.textpath There are many submodules of matplotlib. Most of the Matplotlib utilities lies under the pyplot  submodule.  Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc. Introductory: The basics of creating visualizations with Matplotlib. Matplotlib graphs  where points can be specified in terms of x-y coordinates.  The simplest way of creating a Figure with an Axes is using pyplot.subplots...

First Library: Pandas in Python

Image
Pandas is an open-source library. P andas is a   It provides various data structures and operations for manipulating numerical data and time series. This library is built on top of the NumPy library. Pandas is fast and it has high performance & productivity for users. Pandas data table representation: How to install Pandas in Python? Install pandas via pip--> pip install pandas How to import Pandas? import pandas  How to Create a data frame using Pandas? import pandas as pan df = pan.DataFrame(     {         "Name": [             "Braund, Mr. Owen Harris",             "Allen, Mr. William Henry",             "Bonnell, Miss. Elizabeth",         ],         "Age": [22, 35, 58],         "Sex": ["male", "male", "female"],     } ) print(df) When using a Python dictionary of lists, the dicti...

FuzzyWuzzy Python library

Image
In this article, we see the FuzzyWuzzy library. The name of this library something weird and funny, but it is advantageous. It has a unique way to compare both strings and returns the score out of 100 of how much string is matched. FuzzyWuzzy is a library of  Python which is used for string matching. Fuzzy string matching is the process of finding strings that match a given pattern.   There are many methods of comparing strings in python. Some of the main methods are: Using regex Simple compare Using difflib To work with this library, we need to install it in our Python environment. pip install fuzzywuzzy pip install python-Levenshtein  First, understand the following methods of fuzzywuzzy library: Import these modules:- from fuzzywuzzy import fuzz   from fuzzywuzzy import process  Fuzz Module:    The fuzz module is used to compare the two given strings at a time. It returns a score out of 100 after comparison using the different methods....

How to extract news from website articles and convert it into audio file using python?

In the previous article we saw the request, beautiful soup, and pyttx libraries. In this article, we directly see the example.  Listen news headlines and description of news using python. from bs4 import BeautifulSoup import requests import pyttsx3 #  Url of times of india. url = 'https://timesofindia.indiatimes.com/india/timestopten.cms' #  Make a request to a web page. r = requests.get(url) #  Get a reference to a engine. speaker = pyttsx3.init() def data_extract():     # Create a BeautifulSoup object by passing two arguments.     soup=BeautifulSoup(r.content,'html.parser')          # Web element of news headline.     nav = soup.find_all('td',class_='page_title')          # Web element of content details of news     nav1 = soup.find_all('div',class_='section1')          # Convert text headline into voice.     for i in nav:     ...

How to get current weather information using Python?

Image
 In today's busy lifestyle, we need to choose a smart way of getting weather information. You can do it using a couple of lines. This is a good idea, right? 😊 We need the following things to implement the above small project. What is a Beautifulsoup library?   Beautiful Soup  is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching, and modifying the parse tree. To install Beautifulsoup: pip install bs4   What is the requests library?   The  library is the de facto standard for making HTTP requests in Python. It abstracts the complexities of making requests behind a beautiful, simple API so that you can focus on interacting with services and consuming data in your application. To install requests: pip install requests   What is the time module? This module provides various time-related functions. The time module comes with Python's standard util...