Tutorial by Examples

get_dtype_counts method can be used to see a breakdown of dtypes. In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'], 'D': [True, False, True]}) In [2]: df.get_dtype_counts() Out[2]: bool 1 float64 1 int64 1 obje...
This example shows how to create a prepared statement with an insert statement with parameters, set values to those parameters and then executing the statement. Connection connection = ... // connection created earlier try (PreparedStatement insert = connection.prepareStatement( "i...
In PaaS sites such as Heroku, it is usual to receive the database information as a single URL environment variable, instead of several parameters (host, port, user, password...). There is a module, dj_database_url which automatically extracts the DATABASE_URL environment variable to a Python dictio...
To connect to MySQL you need to use the MySQL Connector/J driver. You can download it from http://dev.mysql.com/downloads/connector/j/ or you can use Maven: <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version...
When you create a function in TypeScript you can specify the data type of the function's arguments and the data type for the return value Example: function sum(x: number, y: number): number { return x + y; } Here the syntax x: number, y: number means that the function can accept two argum...
Example: function hello(name: string): string { return `Hello ${name}!`; } Here the syntax name: string means that the function can accept one name argument and this argument can only be string and (...): string { means that the return value can only be a string Usage: hello('StackOverfl...
The LilyPond notation engraver can be used with LaTeX via the lilypond-book command. First lets create a LaTeX document (with the file extension .lytex) to embed our music in: \documentclass[letterpaper,12pt]{article} \begin{document} \begin{center} {\fontsize{24pt}{24pt}\textbf{Twa Corb...
You can start the mongo shell by running the following command inside your Meteor project: meteor mongo Please note: Starting the server-side database console only works while Meteor is running the application locally. After that, you can list all collections by executing the following command...
Android Studio can configure Kotlin automatically in an Android project. Install the plugin To install the Kotlin plugin, go to File > Settings > Editor > Plugins > Install JetBrains Plugin... > Kotlin > Install, then restart Android Studio when prompted. Configure a project Cr...
TeX formulae can be inserted in the plot using the rc function import matplotlib.pyplot as plt plt.rc(usetex = True) or accessing the rcParams: import matplotlib.pyplot as plt params = {'tex.usetex': True} plt.rcParams.update(params) TeX uses the backslash \ for commands and symbols, whic...
In order to include plots created with matplotlib in TeX documents, they should be saved as pdf or eps files. In this way, any text in the plot (including TeX formulae) is rendered as text in the final document. import matplotlib.pyplot as plt plt.rc(usetex=True) x = range(0, 10) y = [t**2 for t...
You can search Docker Hub for images by using the search command: docker search <term> For example: $ docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. ...
public class MyObject{ public DateTime? TestDate { get; set; } public Func<MyObject, bool> DateIsValid = myObject => myObject.TestDate.HasValue && myObject.TestDate > DateTime.Now; public void DoSomething(){ //We can do this: if(this.TestDate....
Dart has a robust async library, with Future, Stream, and more. However, sometimes you might run into an asynchronous API that uses callbacks instead of Futures. To bridge the gap between callbacks and Futures, Dart offers the Completer class. You can use a Completer to convert a callback into a Fut...
GNU gettext is an extension within PHP that must be included at the php.ini: extension=php_gettext.dll #Windows extension=gettext.so #Linux The gettext functions implement an NLS (Native Language Support) API which can be used to internationalize your PHP applications. Translating strings ...
The following example creates a canvas with 2 points and 1 line in between. You will be able to move the point and the line around. from kivy.app import App from kivy.graphics import Ellipse, Line from kivy.uix.boxlayout import BoxLayout class CustomLayout(BoxLayout): def __init__(se...
When defining a function, use {param1, param2, …} to specify named parameters: void enableFlags({bool bold, bool hidden}) { // ... } When calling a function, you can specify named parameters using paramName: value enableFlags(bold: true, hidden: false);
This example demonstrates how to place 3 buttons in total with 2 buttons being in the first row. Then a wrap occurs, so the last button is in a new row. The constraints are simple strings, in this case "wrap" while placing the component. public class ShowMigLayout { // Create the ...
A linked list is a linear collection of data elements, called nodes, which are linked to other node(s) by means of a "pointer." Below is a singly linked list with a head reference. ┌─────────┬─────────┐ ┌─────────┬─────────┐ HEAD ──▶│ data │"pointer"│──▶...
There is no way to get a value of type a out of an expression of type IO a and there shouldn't be. This is actually a large part of why monads are used to model IO. An expression of type IO a can be thought of as representing an action that can interact with the real world and, if executed, would r...

Page 383 of 1336