Posts

Index Dataframe By Row Number Code Example

Example: pandas df by row index indices = [ 133 , 22 , 19 , 203 , 14 , 1 ] df_by_indices = df . iloc [ indices , : ]

Montserrat Light Font Free Download Code Example

Example: montserrat font <link rel= "preconnect" href= "https://fonts.gstatic.com" > <link href= "https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel= "stylesheet" >

Converting EBCDIC To ASCII In Java

Answer : If I am interpreting this format correctly you have a binary file format with fixed-length records. Some of these records are not character data (COBOL computational fields?) So, you will have to read the records using a more low-level approach processing individual fields of each record: import java.io.*; public class Record { private byte[] kdgex = new byte[2]; // COMP private byte[] b1code = new byte[2]; // COMP private byte[] b1number = new byte[8]; // DISPLAY // other fields public void read(DataInput data) throws IOException { data.readFully(kdgex); data.readFully(b1code); data.readFully(b1number); // other fields } public void write(DataOutput out) throws IOException { out.write(kdgex); out.write(b1code); out.write(b1number); // other fields } } Here I've used byte arrays for the first three fields of the record but you could use other more suitable types where appropriate (like a short for the first field with rea...

Bootswatch Cdn Code Example

Example 1: bootstrap cdn < link rel = " stylesheet " href = " https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css " > Example 2: bootstrap cdn CSS < link rel = " stylesheet " href = " https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css " > JS < script src = " https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js " > </ script > JQuery < script src = " https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js " > </ script > Example 3: bootstrap cdn <!-- Latest compiled and minified CSS --> < link rel = " stylesheet " href = " https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css " integrity = " sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u " crossorigin = " anonymous " > <!-- Optional theme --> < link rel...

Convert Python Datetime To Timestamp In Milliseconds

Answer : In Python 3 this can be done in 2 steps: Convert timestring to datetime object Multiply the timestamp of the datetime object by 1000 to convert it to milliseconds. For example like this: from datetime import datetime dt_obj = datetime.strptime('20.12.2016 09:38:42,76', '%d.%m.%Y %H:%M:%S,%f') millisec = dt_obj.timestamp() * 1000 print(millisec) Output: 1482223122760.0 strptime accepts your timestring and a format string as input. The timestring (first argument) specifies what you actually want to convert to a datetime object. The format string (second argument) specifies the actual format of the string that you have passed. Here is the explanation of the format specifiers from the official documentation: %d - Day of the month as a zero-padded decimal number. %m - Month as a zero-padded decimal number. %Y - Year with century as a decimal number %H - Hour (24-hour clock) as a zero-padded decimal number. %M - Minute as a ze...

Box Shadow Tailwind Css Code Example

Example 1: tailwind box shadow < div class = " shadow-sm ... " > </ div > < div class = " shadow ... " > </ div > < div class = " shadow-md ... " > </ div > < div class = " shadow-lg ... " > </ div > < div class = " shadow-xl ... " > </ div > < div class = " shadow-2xl ... " > </ div > Example 2: tailwind bottom shadow <! DOCTYPE html > < html > < head > < title > Box Shadow </ title > < style type = " text/css " > .box { height : 150 px ; width : 300 px ; margin : 20 px ; border : 1 px solid #ccc ; } .top { box-shadow : 0 -5 px 5 px -5 px #333 ; } .right { box-shadow : -5 px 0 5 px -5 px #333 ; } .bottom { box-shadow : 0 5 px 5 px -5 px #333 ; } .left ...

Create (nested) List From Two Lists In Python

Answer : Use the builtin zip function. It's exactly what you want. From the python manuals: >>> x = [1, 2, 3] >>> y = [4, 5, 6] >>> zipped = zip(x, y) >>> zipped [(1, 4), (2, 5), (3, 6)] Or if you want a list of lists, instead of a list of tuples, you use zip with a list comprehension: >>> zipped = [list(t) for t in zip(x, y)] >>> zipped [[1, 4], [2, 5], [3, 6]] Try: listone = [1,2,3] listtwo = [4,5,6] merged = map(list, zip(listone, listtwo)) zip(listone, listtwo) will return a list of tuples. Since you want a list of lists you need to convert each tuple to a list. map(list, list_of_tuples) call will do exactly that.

Insertion Sort Time Complexity And Space Complexity Code Example

Example: what is time complexity of insertion sort Time Complexity is : If the inversion count is O ( n ) , then the time complexity of insertion sort is O ( n ) . Some Facts about insertion sort : 1. Simple implementation : Jon Bentley shows a three - line C version , and a five - line optimized version [ 1 ] 2. Efficient for ( quite ) small data sets , much like other quadratic sorting algorithms 3. More efficient in practice than most other simple quadratic ( i . e . , O ( n2 ) ) algorithms such as selection sort or bubble sort 4. Adaptive , i . e . , efficient for data sets that are already substantially sorted : the time complexity is O ( kn ) when each element in the input is no more than k places away from its sorted position 5. Stable ; i . e . , does not change the relative order of elements with equal keys 6. In - place ; i . e . , only requires a constant amount O ( 1 ) of additional memory space Online ; i . e . , can sort a list a...

Add Controls Dynamically In Flowlayoutpanel

Answer : For a FlowLayoutPanel, you don't need to specify a .Location since the controls are arranged for you: Represents a panel that dynamically lays out its contents horizontally or vertically. ... The FlowLayoutPanel control arranges its contents in a horizontal or vertical flow direction. Its contents can be wrapped from one row to the next, or from one column to the next. Just change " flowLayoutPanel1 " to the name of your FlowLayoutPanel : for (int i = 0; i < 5; i++) { Button button = new Button(); button.Tag = i; flowLayoutPanel1.Controls.Add(button); }

Range Attribute Unity Code Example

Example: how to set a range for public int or float unity using UnityEngine ; public class Example : MonoBehaviour { // This integer will be shown as a slider, // with the range of 1 to 6 in the Inspector [ Range ( 1 , 6 ) ] public int integerRange ; // This float will be shown as a slider, // with the range of 0.2f to 0.8f in the Inspector [ Range ( 0.2f , 0.8f ) ] public float floatRange ; }

Build HashSet From A Vector In Rust

Answer : Because the operation does not need to consume the vector¹, I think it should not consume it. That only leads to extra copying somewhere else in the program: use std::collections::HashSet; use std::iter::FromIterator; fn hashset(data: &[u8]) -> HashSet<u8> { HashSet::from_iter(data.iter().cloned()) } Call it like hashset(&v) where v is a Vec<u8> or other thing that coerces to a slice. There are of course more ways to write this, to be generic and all that, but this answer sticks to just introducing the thing I wanted to focus on. ¹This is based on that the element type u8 is Copy , i.e. it does not have ownership semantics. The following should work nicely; it fulfills your requirements: use std::collections::HashSet; use std::iter::FromIterator; fn vec_to_set(vec: Vec<u8>) -> HashSet<u8> { HashSet::from_iter(vec) } from_iter() works on types implementing IntoIterator , so a Vec argument is sufficient. Ad...

Pyplot.legend Code Example

Example 1: matplotlib legend import numpy as np import matplotlib . pyplot as plt x = np . linspace ( 0 , 20 , 1000 ) y1 = np . sin ( x ) y2 = np . cos ( x ) plt . plot ( x , y1 , "-b" , label = "sine" ) plt . plot ( x , y2 , "-r" , label = "cosine" ) plt . legend ( loc = "upper left" ) plt . ylim ( - 1.5 , 2.0 ) plt . show ( ) Example 2: plt.legend( plt . legend ( [ 'first' , 'second' ] ) ; Example 3: python how to add a figure legend at the best position # Short answer : # matplotlib . pyplot places the legend in the "best" location by default # To add a legend to your plot , call plt . legend ( ) # Example usage : import matplotlib . pyplot as plt x1 = [ 1 , 2 , 3 ] # Invent x and y data to be plotted y1 = [ 4 , 5 , 6 ] x2 = [ 1 , 3 , 5 ] y2 = [ 6 , 5 , 4 ] plt . plot ( x1 , y1 , label = "Dataset_1" ) # Use label = "data_name" ...

Android Button Border Radius Code Example

Example 1: rounded corners button in android <?xml version="1.0" encoding="utf-8"?> < shape xmlns: android = " http://schemas.android.com/apk/res/android " > < corners android: radius = " 24dp " /> < solid android: color = " #F00 " /> </ shape > Example 2: how to add corner radius in android button < shape xmlns: android = " http://schemas.android.com/apk/res/android " android: shape = " rectangle " > < solid android: color = " @color/primary " /> < corners android: radius = " 5dp " /> </ shape >

Bootstrap Multi Tags Input Cdn Code Example

Example: bootstrap multi tags input cdn Bootstrap Tagsinput how to get multiple values as an array ...

Cannot Connect To The Docker Daemon At Tcp://localhost:2375. Is The Docker Daemon Running? Wsl Code Example

Example: WSL connect docker daemon to docker for windows echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc && source ~/.bashrc

Crontab Every 3 Hours Code Example

Example 1: cron every 3 hours 0 */3 * * * Example 2: crontab every 30 minutes between hours // from 08h to 17h (until 17:30) */30 8-17 * * * // from 08h to 17h, at number '5' (until 17:35) 5,30 8-17 * * * Example 3: cron every two hours 0 */2 * * *