Tutorial by Examples

df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6], 'c': [7, 8, 9]}) To list the column names in a DataFrame: >>> list(df) ['a', 'b', 'c'] This list comprehension method is especially useful when using the debugger: >>> [c for c in df] ['a', 'b', 'c'] This is the long w...
NuGet version Before you start: make sure your NuGet version is up to date. In Visual Studio, go to Tools > Extensions and Updates, then Updates > Visual Studio Gallery. Check if there is a NuGet Update available and install it. Or, you can uninstall the existing nuget and reinstall it. It w...
End a line with two or more spaces to create a line break. Ending a line with no spaces or with just one space doesn't create a line beak. Use two or more spaces to create a line break. Use an empty line to make a new paragraph. Ending a line with no spaces or with just one space...
SilverStripe can be installed via composer or through the extraction of downloaded zip file. To install through composer we run the following command composer create-project silverstripe/installer /path/to/project 3.4.0 A download zip file can be found on the download page of the SilverStripe w...
In Fortran functions and subroutines need to be explicitly declared as recursive, if they are to call themselves again, directly or indirectly. Thus, a recursive implementation of the Fibonacci series could look like this: recursive function fibonacci(term) result(fibo) integer, intent(in) :: te...
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...
where clauses can be negated using the where.not syntax: class Person < ApplicationRecord #attribute :first_name, :string end people = Person.where.not(first_name: ['Mark', 'Mary']) # => SELECT "people".* FROM "people" WHERE "people"."first_name&quot...
You can validate any object, even plain ruby. class User include ActiveModel::Validations attr_reader :name, :age def initialize(name, age) @name = name @age = age end validates :name, presence: true validates :age, numericality: { only_integer: true, greater_than...
Elixir comes with integers and floating point numbers. An integer literal can be written in decimal, binary, octal and hexadecimal formats. iex> x = 291 291 iex> x = 0b100100011 291 iex> x = 0o443 291 iex> x = 0x123 291 As Elixir uses bignum arithmetic, the range of int...
To start using Vue.js, make sure you have the script file included in your HTML. For example, add the following to your HTML. <script src="https://npmcdn.com/vue/dist/vue.js"></script> Simple Example HTML template <div id="app"> {{ message }} </div&...
If you want to support a url parameter more complex than an id number, you may run into trouble with the parser if the value contains a period. Anything following a period will be assumed to be a format (i.e. json, xml). You can work around this limitation by using a constraint to broaden the accep...
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 ...
Swift Ctrl + Drag from the UItextfield in MainStoryboard to the ViewController Class and create a UITextField Outlet After that select the UItextField again and Ctrl+drag in ViewController class but this time select Action connection and on storage select Did End On Exit then click connect. ...
As Rails follows the MVC pattern Views are where your "templates" are for your actions. Let's say you have a controller articles_controller.rb. For this controller you would have a folder in views called app/views/articles: app |-- controllers | '-- articles_controller.rb | '-- vie...
You can use an initializer to set default property values: struct Example { var upvotes: Int init() { upvotes = 42 } } let myExample = Example() // call the initializer print(myExample.upvotes) // prints: 42 Or, specify default property values as a part of the property...
struct MetricDistance { var distanceInMeters: Double init(fromCentimeters centimeters: Double) { distanceInMeters = centimeters / 100 } init(fromKilometers kilos: Double) { distanceInMeters = kilos * 1000 } } let myDistance = MetricDistance(fromCentim...
The Number constructor has some built in constants that can be useful Number.MAX_VALUE; // 1.7976931348623157e+308 Number.MAX_SAFE_INTEGER; // 9007199254740991 Number.MIN_VALUE; // 5e-324 Number.MIN_SAFE_INTEGER; // -9007199254740991 Number.EPSILON; // 0.000...
open my $fh, '<', $filename or die "Could not open $filename for reading: $!"; my $contents = do { local $/; <$fh> }; After opening the file (read man perlio if you want to read specific file encodings instead of raw bytes), the trick is in the do block: <$fh>, the ...
Using the idiom from The Manual Way several times in a script soon gets tedious so you might want to try a module. use Path::Tiny; my $contents = path($filename)->slurp; You can pass a binmode option if you need control over file encodings, line endings etc. - see man perlio: my $contents =...

Page 217 of 1336