Types of columns can be checked by .dtypes atrribute of DataFrames.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': [True, False, True]})
In [2]: df
Out[2]:
A B C
0 1 1.0 True
1 2 2.0 False
2 3 3.0 True
In [3]: df.dtypes
Out[3]:
A int64
...
astype() method changes the dtype of a Series and returns a new Series.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0],
'C': ['1.1.2010', '2.1.2011', '3.1.2011'],
'D': ['1 days', '2 days', '3 days'],
...
select_dtypes method can be used to select columns based on dtype.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'],
'D': [True, False, True]})
In [2]: df
Out[2]:
A B C D
0 1 1.0 a True
1 2 2.0 b False
2...
get_dtype_counts method can be used to see a breakdown of dtypes.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'],
'D': [True, False, True]})
In [2]: df.get_dtype_counts()
Out[2]:
bool 1
float64 1
int64 1
obje...
This example shows how to create a prepared statement with an insert statement with parameters, set values to those parameters and then executing the statement.
Connection connection = ... // connection created earlier
try (PreparedStatement insert = connection.prepareStatement(
"i...
When you create a function in TypeScript you can specify the data type of the function's arguments and the data type for the return value
Example:
function sum(x: number, y: number): number {
return x + y;
}
Here the syntax x: number, y: number means that the function can accept two argum...
Example:
function hello(name: string): string {
return `Hello ${name}!`;
}
Here the syntax name: string means that the function can accept one name argument and this argument can only be string and (...): string { means that the return value can only be a string
Usage:
hello('StackOverfl...
The LilyPond notation engraver can be used with LaTeX via the lilypond-book command. First lets create a LaTeX document (with the file extension .lytex) to embed our music in:
\documentclass[letterpaper,12pt]{article}
\begin{document}
\begin{center}
{\fontsize{24pt}{24pt}\textbf{Twa Corb...
TeX formulae can be inserted in the plot using the rc function
import matplotlib.pyplot as plt
plt.rc(usetex = True)
or accessing the rcParams:
import matplotlib.pyplot as plt
params = {'tex.usetex': True}
plt.rcParams.update(params)
TeX uses the backslash \ for commands and symbols, whic...
In order to include plots created with matplotlib in TeX documents, they should be saved as pdf or eps files. In this way, any text in the plot (including TeX formulae) is rendered as text in the final document.
import matplotlib.pyplot as plt
plt.rc(usetex=True)
x = range(0, 10)
y = [t**2 for t...
public class MyObject{
public DateTime? TestDate { get; set; }
public Func<MyObject, bool> DateIsValid = myObject => myObject.TestDate.HasValue && myObject.TestDate > DateTime.Now;
public void DoSomething(){
//We can do this:
if(this.TestDate....
When defining a function, use {param1, param2, …} to specify named parameters:
void enableFlags({bool bold, bool hidden}) {
// ...
}
When calling a function, you can specify named parameters using paramName: value
enableFlags(bold: true, hidden: false);
This example demonstrates how to place 3 buttons in total with 2 buttons being in the first row. Then a wrap occurs, so the last button is in a new row.
The constraints are simple strings, in this case "wrap" while placing the component.
public class ShowMigLayout {
// Create the ...
In many Excel applications, the VBA code takes actions directed at the workbook in which it's contained. You save that workbook with a ".xlsm" extension and the VBA macros only focus on the worksheets and data within. However, there are often times when you need to combine or merge data fr...
If you want to access a workbook that's already open, then getting the assignment from the Workbooks collection is straightforward:
dim myWB as Workbook
Set myWB = Workbooks("UsuallyFullPathnameOfWorkbook.xlsx")
If you want to create a new workbook, then use the Workbooks collection o...
To create a project called helloworld run:
stack new helloworld simple
This will create a directory called helloworld with the files necessary for a Stack project.
Stackage is a repository for Haskell packages. We can add these packages to a stack project.
Adding lens to a project.
In a stack project, there is a file called stack.yaml. In stack.yaml there is a segment that looks like:
resolver: lts-6.8
Stackage keeps a list of packages for every revision...
Example uses of $(document).ready():
Attaching event handlers
Attach jQuery event handlers
$(document).ready(function() {
$("button").click(function() {
// Code for the click function
});
});
Run jQuery code after the page structure is created
jQuery(function($) ...
A basic example of HTTP server.
write following code in http_server.js file:
var http = require('http');
var httpPort = 80;
http.createServer(handler).listen(httpPort, start_callback);
function handler(req, res) {
var clientIP = req.connection.remoteAddress;
var connectUsi...
a basic example for http client:
write the follwing code in http_client.js file:
var http = require('http');
var options = {
hostname: '127.0.0.1',
port: 80,
path: '/',
method: 'GET'
};
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode)...