In [1]: df1 = pd.DataFrame({'x': [1, 2, 3], 'y': ['a', 'b', 'c']})
In [2]: df2 = pd.DataFrame({'y': ['b', 'c', 'd'], 'z': [4, 5, 6]})
In [3]: df1
Out[3]:
x y
0 1 a
1 2 b
2 3 c
In [4]: df2
Out[4]:
y z
0 b 4
1 c 5
2 d 6
Inner join:
Uses the intersection ...
When you inherit from a class with a property, you can provide a new implementation for one or more of the property getter, setter or deleter functions, by referencing the property object on the parent class:
class BaseClass(object):
@property
def foo(self):
return some_calculate...
The following example listens to window.onerror event and uses an image beacon technique to send the information through the GET parameters of an URL.
var hasLoggedOnce = false;
// Some browsers (at least Firefox) don't report line and column numbers
// when event is handled through window.addE...
Attributes are name-value pairs associated with an element.
They are represented by values in single or double quotes inside the opening element tag, or the empty element tag if it is an empty element.
<document>
<anElement foo="bar" abc='xyz'><!-- some content -->&l...
Packages are bundles of classes. Every class must be declared within a package using the package statement. The package statement is followed by the name of your package, or followed by nothing in the case of adding classes to the top-level package. Sub-packages are created using dot (.) delimitatio...
Arrays can have more than one dimension. The following example creates a two-dimensional array of ten rows and ten columns:
int[,] arr = new int[10, 10];
An array of three dimensions:
int[,,] arr = new int[10, 10, 10];
You can also initialize the array upon declaration:
int[,] arr = new int...
Import the numpy module to use any part of it.
import numpy as np
Most examples will use np as shorthand for numpy. Assume "np" means "numpy" in code examples.
x = np.array([1,2,3,4])
This makes image masked to the shape of the letters of the label:
Objective-C
self.maskImage.layer.mask = self.maskLabel.layer;
self.maskImage.layer.masksToBounds = YES;
Swift 3
maskImageView.mask = maskLabel
maskImageView.masksToBounds = true
Here is the result:
A comment is marked by an apostrophe ('), and ignored when the code executes. Comments help explain your code to future readers, including yourself.
Since all lines starting with a comment are ignored, they can also be used to prevent code from executing (while you debug or refactor). Placing an ap...
Usually authentication&authorization processes are performed by built-in cookie and token supports in .net MVC. But if you decide to do it yourself with Session you can use below logic for both page requests and ajax requests.
public class SessionControl : ActionFilterAttribute
{
public o...
This is an example of how to use the generic type TFood inside Eat method on the class Animal
public interface IFood
{
void EatenBy(Animal animal);
}
public class Grass: IFood
{
public void EatenBy(Animal animal)
{
Console.WriteLine("Grass was eaten by: {0}",...
arr = np.arange(7)
print(arr)
# Out: array([0, 1, 2, 3, 4, 5, 6])
Comparison with a scalar returns a boolean array:
arr > 4
# Out: array([False, False, False, False, False, True, True], dtype=bool)
This array can be used in indexing to select only the numbers greater than 4:
arr[arr&...
The numpy.reshape (same as numpy.ndarray.reshape) method returns an array of the same total size, but in a new shape:
print(np.arange(10).reshape((2, 5)))
# [[0 1 2 3 4]
# [5 6 7 8 9]]
It returns a new array, and doesn't operate in place:
a = np.arange(12)
a.reshape((3, 4))
print(a)
# ...
Along with classic way of route definition MVC WEB API 2 and then MVC 5 frameworks introduced Attribute routing:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
// This...
Draw samples from a normal (gaussian) distribution
# Generate 5 random numbers from a standard normal distribution
# (mean = 0, standard deviation = 1)
np.random.randn(5)
# Out: array([-0.84423086, 0.70564081, -0.39878617, -0.82719653, -0.4157447 ])
# This result can also be achieved with t...
Install
npm is bundled with Node.js, so if you install Node.js you'll automatically have npm installed too. You can choose between a Current and a LTS version
Windows
For Microsoft Windows you can download a MSI installer from https://nodejs.org/en/download/.
OS X
For Apple OS X you can downloa...