Tutorial by Examples: c

Sometimes we want to prepare a context for each test to be run under. The setUp method is run prior to each test in the class. tearDown is run at the end of every test. These methods are optional. Remember that TestCases are often used in cooperative multiple inheritance so you should be careful to...
Pandas uses provides multiple ways to make graphs of the data inside the data frame. It uses matplotlib for that purpose. The basic graphs have their wrappers for both DataFrame and Series objects: Line Plot df = pd.DataFrame({'x': [10, 8, 10, 7, 7, 10, 9, 9], 'y': [6, 4, 5, 5...
Strings in a Series can be sliced using .str.slice() method, or more conveniently, using brackets (.str[]). In [1]: ser = pd.Series(['Lorem ipsum', 'dolor sit amet', 'consectetur adipiscing elit']) In [2]: ser Out[2]: 0 Lorem ipsum 1 dolor sit amet 2 cons...
str.contains() method can be used to check if a pattern occurs in each string of a Series. str.startswith() and str.endswith() methods can also be used as more specialized versions. In [1]: animals = pd.Series(['cat', 'dog', 'bear', 'cow', 'bird', 'owl', 'rabbit', 'snake']) Check if strings con...
In [1]: ser = pd.Series(['lORem ipSuM', 'Dolor sit amet', 'Consectetur Adipiscing Elit']) Convert all to uppercase: In [2]: ser.str.upper() Out[2]: 0 LOREM IPSUM 1 DOLOR SIT AMET 2 CONSECTETUR ADIPISCING ELIT dtype: object All lowercase: In [3]: ser...
Given the following DataFrame: In [11]: df = pd.DataFrame(np.random.randn(6, 3), columns=['A', 'B', 'C']) In [12]: df.set_index(['A', 'B'], inplace=True) In [13]: df Out[13]: C A B 0.902764 -0.259656 -1.864541 -0.695893 0.308893 0...
It's easier to implement some UDFs on the worksheet if full column references can be passed in as parameters. However, due to the explicit nature of coding, any loop involving these ranges may be processing hundreds of thousands of cells that are completely empty. This reduces your VBA project (and ...
An Option is a data structure that contains either a single value, or no value at all. An Option can be thought of as collections of zero or one elements. Option is an abstract class with two children: Some and None. Some contains a single value, and None contains no value. Option is useful in ex...
The Foundation framework provides the Operation type, which represents a high-level object that encapsulates a portion of work that may be executed on a queue. Not only does the queue coordinate the performance of those operations, but you can also establish dependencies between operations, create c...
<svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <polyline points="10,5 25,15 20,10" /> </svg>
public class SignUpActivity extends BaseAppCompatActivity { @BindView(R.id.tIETSignUpEmail) EditText mEditEmail; @BindView(R.id.tIETSignUpPassword) EditText mEditPassword; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCrea...
public class ChangePasswordActivity extends BaseAppCompatActivity implements ReAuthenticateDialogFragment.OnReauthenticateSuccessListener { @BindView(R.id.et_change_password) EditText mEditText; private FirebaseUser mFirebaseUser; @OnClick(R.id.btn_change_password) void on...
public class ReAuthenticateDialogFragment extends DialogFragment { @BindView(R.id.et_dialog_reauthenticate_email) EditText mEditTextEmail; @BindView(R.id.et_dialog_reauthenticate_password) EditText mEditTextPassword; private OnReauthenticateSuccessListener mOnReauthenticat...
Java configuration is typically done by applying the @Configuration annotation to a class to suggest that a class contains bean definitions. The bean definitions are specified by applying the @Bean annotation to a method that returns an object. @Configuration // This annotation tells the Applicati...
Xml configuration is typically done by defining beans within an xml file, using Spring's specific beans schema. Under the root beans element, typical bean definition would be done using the bean subelement. <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="htt...
You can combine the results of two identically structured queries with the UNION keyword. For example, if you wanted a list of all contact info from two separate tables, authors and editors, for instance, you could use the UNION keyword like so: select name, email, phone_number from authors u...
Julia uses similar binary operators for basic arithmetic operations as does mathematics or other programming languages. Most operators can be written in infix notation (that is, placed in between the values being computed). Julia has an order of operations that matches the common convention in mathe...
So you want to deploy your app to multiple sites? and your project has too many dependencies to install them one-by-one? Npm has a solution just issue the following command: npm init In the project's root folder then follow the instructions on screen (type in the desired value then press enter) ...
In many languages, new instances of a class are created using a special new keyword. In Ruby, new is also used to create instances of a class, but it isn't a keyword; instead, it's a static/class method, no different from any other static/class method. The definition is roughly this: class MyClass ...
This example sorts elements in ascending order of a key using a map. You can use any type, including class, instead of std::string, in the example below. #include <iostream> #include <utility> #include <map> int main() { std::map<double, std::string> sorted_map; ...

Page 319 of 826