Tutorial by Examples: amp

A series is a one-dimension data structure. It's a bit like a supercharged array, or a dictionary. import pandas as pd s = pd.Series([10, 20, 30]) >>> s 0 10 1 20 2 30 dtype: int64 Every value in a series has an index. By default, the indices are integers, running fro...
from pandas_datareader import data # Only get the adjusted close. aapl = data.DataReader("AAPL", start='2015-1-1', end='2015-12-31', data_source='yahoo')['Adj Close'] >>> aapl.plot(title='AAPL Adj. C...
<?php use yii\db\Migration; class m150101_185401_create_news_table extends Migration { public function up() { } public function down() { echo "m101129_185401_create_news_table cannot be reverted.\n"; return false; } /* // Use safeUp/safeDown to run migra...
Given any value of type Int or Long to render a human readable string: fun Long.humanReadable(): String { if (this <= 0) return "0" val units = arrayOf("B", "KB", "MB", "GB", "TB", "EB") val digitGroups = (Mat...
A common use case for extension methods is to improve an existing API. Here are examples of adding exist, notExists and deleteRecursively to the Java 7+ Path class: fun Path.exists(): Boolean = Files.exists(this) fun Path.notExists(): Boolean = !this.exists() fun Path.deleteRecursively(): Bool...
With this declaration: fun Temporal.toIsoString(): String = DateTimeFormatter.ISO_INSTANT.format(this) You can now simply: val dateAsString = someInstant.toIsoString()
Taken from jQuery.ajax API web site: $.ajax({ method: "POST", url: "some.php", data: { name: "John", location: "Boston" }, success: function(msg) { alert("Data Saved: " + msg); }, error: ...
import pandas as pd import numpy as np np.random.seed(0) # create an array of 5 dates starting at '2015-02-24', one per minute rng = pd.date_range('2015-02-24', periods=5, freq='T') df = pd.DataFrame({ 'Date': rng, 'Val': np.random.randn(len(rng)) }) print (df) # Output: # ...
import pandas as pd import numpy as np Using from_tuples: np.random.seed(0) tuples = list(zip(*[['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux'], ['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']])) idx = pd...
In the simple example, we simply set the width of the rectangle to that of it's parent. Let's consider a more complicated example: ApplicationWindow { visible: true width: 400 height: 640 Rectangle{ id: rect anchors.centerIn: parent height: 100 ...
Dependencies npm i -D webpack babel-loader webpack.config.js const path = require('path'); module.exports = { entry: { app: ['babel-polyfill', './src/'], }, output: { path: __dirname, filename: './dist/[name].js', }, resolve: { extensions: ['', '.js'], }...
Required modules npm install --save-dev webpack extract-text-webpack-plugin file-loader css-loader style-loader Folder structure . └── assets    ├── css     ├── images    └── js webpack.config.js const webpack = require('webpack'); const ExtractTextPlugin = require('extract-text-webp...
Python has only limited support for parsing ISO 8601 timestamps. For strptime you need to know exactly what format it is in. As a complication the stringification of a datetime is an ISO 8601 timestamp, with space as a separator and 6 digit fraction: str(datetime.datetime(2016, 7, 22, 9, 25, 59, 55...
letters = list('abcde') Select three letters randomly (with replacement - same item can be chosen multiple times): np.random.choice(letters, 3) ''' Out: array(['e', 'e', 'd'], dtype='<U1') ''' Sampling without replacement: np.random.choice(letters, 3, replace=False) ''' Out...
Install the necessary Python Library via: $ pip install elasticsearch Connect to Elasticsearch, Create a Document (e.g. data entry) and "Index" the document using Elasticsearch. from datetime import datetime from elasticsearch import Elasticsearch # Connect to Elasticsearch using ...
For ease of testing, sklearn provides some built-in datasets in sklearn.datasets module. For example, let's load Fisher's iris dataset: import sklearn.datasets iris_dataset = sklearn.datasets.load_iris() iris_dataset.keys() ['target_names', 'data', 'target', 'DESCR', 'feature_names'] You can ...
package { import flash.text.TextField; import flash.display.Sprite; public class TextHello extends Sprite { public function TextHello() { var tf:TextField = new TextField(); tf.text = "Hello World!" tf.x = 50; tf...
sqldf() from the package sqldf allows the use of SQLite queries to select and manipulate data in R. SQL queries are entered as character strings. To select the first 10 rows of the "diamonds" dataset from the package ggplot2, for example: data("diamonds") head(diamonds) #...
Signals and slots are used for communication between objects. The signals and slots mechanism is a central feature of Qt and probably the part that differs most from the features provided by other frameworks. The minimal example requires a class with one signal, one slot and one connection: counte...
PropertyPossible Valuesdisplaygrid / inline-grid The CSS Grid is defined as a display property. It applies to a parent element and its immediate children only. Consider the following markup: <section class="container"> <div class="item1">item1</div> &lt...

Page 5 of 46