Tutorial by Examples: ect

import pandas as pd import numpy as np np.random.seed(123) x = np.random.standard_normal(4) y = range(4) df = pd.DataFrame({'X':x, 'Y':y}) >>> df X Y 0 -1.085631 0 1 0.997345 1 2 0.282978 2 3 -1.506295 3
A select case construct conditionally executes one block of constructs or statements depending on the value of a scalar expression in a select case statement. This control construct can be considered as a replacement for computed goto. [name:] SELECT CASE (expr) [CASE (case-value [, case-value] .....
Move Blue to the beginning of the array: NSMutableArray *myColors = [NSMutableArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; NSUInteger fromIndex = 2; NSUInteger toIndex = 0; id blue = [[[self.array objectAtIndex:fromIndex] retain]...
Oracle's CONNECT BY functionality provides many useful and nontrivial features that are not built-in when using SQL standard recursive CTEs. This example replicates these features (with a few additions for sake of completeness), using SQL Server syntax. It is most useful for Oracle developers findin...
Deleting files The unlink function deletes a single file and returns whether the operation was successful. $filename = '/path/to/file.txt'; if (file_exists($filename)) { $success = unlink($filename); if (!$success) { throw new Exception("Cannot delete $filename&qu...
fs.access() determines whether a path exists and what permissions a user has to the file or directory at that path. fs.access doesn't return a result rather, if it doesn't return an error, the path exists and the user has the desired permissions. The permission modes are available as a property on ...
Due to Node's asynchronous nature, creating or using a directory by first: checking for its existence with fs.stat(), then creating or using it depending of the results of the existence check, can lead to a race condition if the folder is created between the time of the check and the time of ...
Defining a member block inside a resource creates a route that can act on an individual member of that resource-based route: resources :posts do member do get 'preview' end end This generates the following member route: get '/posts/:id/preview', to: 'posts#preview' # preview_post_p...
# Create a sample DF df = pd.DataFrame(np.random.randn(5, 3), columns=list('ABC')) # Show DF df A B C 0 -0.467542 0.469146 -0.861848 1 -0.823205 -0.167087 -0.759942 2 -1.508202 1.361894 -0.166701 3 0.394143 -0.287349 -0.978102 4 -0.160431 1.054736 -0.785250 ...
Pass data in native Python form, for example list, dict, str, None, bool, etc. IceCream.objects.create(metadata={ 'date': '1/1/2016', 'ordered by': 'Jon Skeet', 'buyer': { 'favorite flavor': 'vanilla', 'known for': ['his rep on SO', 'writing a book'] }, ...
The only time the garbage collector is needed is if you have a reference cycle. The simples example of a reference cycle is one in which A refers to B and B refers to A, while nothing else refers to either A or B. Neither A or B are accessible from anywhere in the program, so they can safely be dest...
Removing a variable name from the scope using del v, or removing an object from a collection using del v[item] or del[i:j], or removing an attribute using del v.name, or any other way of removing references to an object, does not trigger any destructor calls or any memory being freed in and of itsel...
The iloc (short for integer location) method allows to select the rows of a dataframe based on their position index. This way one can slice dataframes just like one does with Python's list slicing. df = pd.DataFrame([[11, 22], [33, 44], [55, 66]], index=list("abc")) df # Out: # 0...
It is possible to detect whether an operator or function can be called on a type. To test if a class has an overload of std::hash, one can do this: #include <functional> // for std::hash #include <type_traits> // for std::false_type and std::true_type #include <utility> // for s...
Swift func createCollectionView() { let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout() let collectionView = UICollectionView(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height), collectionViewLayout: layout) collectionView.dataSource = sel...
// MARK: - UICollectionViewDelegateFlowLayout extension ViewController: UICollectionViewDelegateFlowLayout { func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { return ...
ansible -i hosts -m ping targethost -i hosts defines the path to inventory file targethost is the name of the host in the hosts file
Here's how you can destructure a vector: (def my-vec [1 2 3]) Then, for example within a let block, you can extract values from the vector very succinctly as follows: (let [[x y] my-vec] (println "first element:" x ", second element: " y)) ;; first element: 1 , second ele...
public void iterateAndFilter() throws IOException { Path dir = Paths.get("C:/foo/bar"); PathMatcher imageFileMatcher = FileSystems.getDefault().getPathMatcher( "regex:.*(?i:jpg|jpeg|png|gif|bmp|jpe|jfif)"); try (Direc...
Iterating over List List<String> names = new ArrayList<>(Arrays.asList("Clementine", "Duran", "Mike")); Java SE 8 names.forEach(System.out::println); If we need parallelism use names.parallelStream().forEach(System.out::println); Java SE 5 fo...

Page 16 of 99