Python tutorials

Reading and Writing XML Files in Python

XML, or Extensible Markup Language, is a markup-language that is commonly used to structure, store, and transfer data between systems. While not as common as it used to be, it is still used in services like RSS and SOAP, as well as for structuring files like Microsoft Office documents. With Python being a popular language for the web and data analysis, it’s likely you’ll need to read or write XML data at some point, in which case you’re in luck. […]

Read more

Understanding Python’s “yield” Keyword

The yield keyword in Python is used to create generators. A generator is a type of collection that produces items on-the-fly and can only be iterated once. By using generators you can improve your application’s performance and consume less memory as compared to normal collections, so it provides a nice boost in performance. In this article we’ll explain how to use the yield keyword in Python and what it does exactly. But first, let’s study the difference between a simple […]

Read more

Using Machine Learning to Predict the Weather: Part 3

This is the final article on using machine learning in Python to make predictions of the mean temperature based off of meteorological weather data retrieved from Weather Underground as described in part one of this series. The topic of this final article will be to build a neural network regressor using Google’s Open Source TensorFlow library. For a general introduction into TensorFlow, as well a discussion of installation methods, please see Mihajlo Pavloski’s excellent post TensorFlow Neural Network Tutorial. Topics […]

Read more

Formatting Strings with Python

Introduction Sooner or later string formatting becomes a necessary evil for most programmers. More so in the past before the thick client GUI era, but the need to have a specific string representation is still a common enough use case. My first introduction was back in college when I had an old-school prof that had a impure love for making us write Java console applications with neurotic specifications for outputting with the printf(…) function. One thing that held true then […]

Read more

Python zlib Library Tutorial

What is Python zlib The Python zlib library provides a Python interface to the zlib C library, which is a higher-level abstraction for the DEFLATE lossless compression algorithm. The data format used by the library is specified in the RFC 1950 to 1952, which is available at http://www.ietf.org/rfc/rfc1950.txt. The zlib compression format is free to use, and is not covered by any patent, so you can safely use it in commercial products as well. It is a lossless compression format […]

Read more

A SQLite Tutorial with Python

Introduction This tutorial will cover using SQLite in combination with Python’s sqlite3 interface. SQLite is a single file relational database bundled with most standard Python installs. SQLite is often the technology of choice for small applications, particularly those of embedded systems and devices like phones and tablets, smart appliances, and instruments. However, it is not uncommon to hear it being used for small to medium web and desktop applications. Creating a Database and Making a Connection Creating a new SQLite […]

Read more

Scheduling Jobs with python-crontab

What is Crontab Cron is a software utility that allows us to schedule tasks on Unix-like systems. The name is derived from the Greek word “Chronos”, which means “time”. The tasks in Cron are defined in a crontab, which is a text file containing the commands to be executed. The syntax used in a crontab is described below in this article. Python presents us with the crontab module to manage scheduled jobs via Cron. The functions available in it allow […]

Read more

K-Means Clustering with Scikit-Learn

Introduction K-means clustering is one of the most widely used unsupervised machine learning algorithms that forms clusters of data based on the similarity between data instances. For this particular algorithm to work, the number of clusters has to be defined beforehand. The K in the K-means refers to the number of clusters. The K-means algorithm starts by randomly choosing a centroid value for each cluster. After that the algorithm iteratively performs three steps: (i) Find the Euclidean distance between each […]

Read more

Levenshtein Distance and Text Similarity in Python

Introduction Writing text is a creative process that is based on thoughts and ideas which come to our mind. The way that the text is written reflects our personality and is also very much influenced by the mood we are in, the way we organize our thoughts, the topic itself and by the people we are addressing it to – our readers. In the past it happened that two or more authors had the same idea, wrote it down separately, […]

Read more

Accessing the Twitter API with Python

Introduction One thing that Python developers enjoy is surely the huge number of resources developed by its big community. Python-built application programming interfaces (APIs) are a common thing for web sites. It’s hard to imagine that any popular web service will not have created a Python API library to facilitate the access to its services. A few ideas of such APIs for some of the most popular web services could be found here. In fact, “Python wrapper” is a more […]

Read more
1 172 173 174 175 176 181