Posts

Showing posts from December, 2017

Check If Single Cell Value Is NaN In Pandas

Answer : Try this: import pandas as pd import numpy as np from pandas import * >>> L = [4, nan ,6] >>> df = Series(L) >>> df 0 4 1 NaN 2 6 >>> if(pd.isnull(df[1])): print "Found" Found >>> if(np.isnan(df[1])): print "Found" Found STEP 1.) df[df.isnull().any(1)] ----> Will give you dataframe with rows and column, if any value there is nan. STEP 2.) this will give you location in dataframe where exactly value is nan. then you could do if(**df.iloc[loc_row,loc_colum]==np.nan**): print"your code here" You can use "isnull" with "at" to check a specific value in a dataframe. For example: import pandas as pd import numpy as np df = pd.DataFrame([[np.nan, 2], [1, 3], [4, 6]], columns=['A', 'B']) Yeilds: A B 0 NaN 2 1 1.0 3 2 4.0 6 To check the values: pd.isnull(df.at[0,'A']) -> True pd.isnu

Bootstrap Responsive Background Image Code Example

Example 1: add background image in bootstrap 5 < div class = " has-bg-img bg-purple bg-blend-screen " > < h4 > Background blend mode: Multiply </ h4 > < img class = " bg-img " src = " ... " > </ div > Example 2: Scaling Images and Videos css .container { width: 50%; height: 200px; overflow: hidden; } .container img { max-width: 100%; height: auto; display: block; }

7400 Series CMOS Vs 4000 Series Logic IC

Answer : The difference depends on your system definition. On the one hand, 74HC operates over a limited voltage range, with 6 volts specified as the maximum supply voltage. The CD4000 series, on the other hand, is rated to a maximum of 18 volts, so it may well be easier to use the CD4000 series in a battery-operated system. If the limited voltage range of the 74HC line is not a problem, the line is much faster. For instance, comparing the CD4011/74HC00 (Quad 2-input NAND gates) gives propagation delays at 5 volts of 90 nsec (typ) vs 7 nsec. For the CD4063 vs the 74HC85 (4-bit magnitude comparator) the numbers are 625 nsec (typ) vs. 63 nsec. The CD40192 4-bit up/down counter has a typical count frequency of 4 MHz, while the 74HC192 goes at 36 MHz. It's worth keeping in mind that both lines run faster at higher Vdd, so a CD4000 at 15 volts will do better than the numbers here, but the order of magnitude difference is not erased. And yes, the 74HC series is designed to rough

Bootstrap Heading Examples

Example: bootstrap heading h1. Bootstrap heading h2. Bootstrap heading h3. Bootstrap heading h4. Bootstrap heading h5. Bootstrap heading h6. Bootstrap heading

Checking For A Dirty Index Or Untracked Files With Git

Answer : The key to reliably “scripting” Git is to use the ‘plumbing’ commands. The developers take care when changing the plumbing commands to make sure they provide very stable interfaces (i.e. a given combination of repository state, stdin, command line options, arguments, etc. will produce the same output in all versions of Git where the command/option exists). New output variations in plumbing commands can be introduced via new options, but that can not introduce any problems for programs that have already been written against older versions (they would not be using the new options, since they did not exist (or at least were not used) at the time the script was written). Unfortunately the ‘everyday’ Git commands are the ‘porcelain’ commands, so most Git users may not be familiar with with the plumbing commands. The distinction between porcelain and plumbing command is made in the main git manpage (see subsections titled High-level commands (porcelain) and Low-level commands

Alter Auto_increment Code Example

Example 1: auto_increment mysql ALTER TABLE User AUTO_INCREMENT = 1 ; Example 2: alter table auto_increment ALTER TABLE ALLITEMS CHANGE itemid itemid INT ( 10 ) AUTO_INCREMENT PRIMARY KEY ;

90f To C Code Example

Example: convert fahrenheit to celsius import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int far = sc . nextInt ( ) ; int cel = ( far - 32 ) * 5 / 9 ; System . out . printf ( "%d Fahrenheit is %d Celsius" , far , cel ) ; } }

All Games Made By Io Games Code Example

Example: most popular io games zombsroyale.io

Can I Buy A Horse For My Follower?

Image
Answer : Current mods that can allow you to buy or acquire horses for your followers to use: Original / Legendary Edition (PC) Mounted Followers ...this mod once installed lets your follower have and ride a horse that will spawn near your last ridden horse. It works with stolen horses, quest horses, but of course works best with stabled horses. Note: 1 - I suggest you to never mount the follower horse, it may result in the follower mounting yours and after you dismount you'd have to catch your horse that tries to go back to stables. 2 - You can fast travel but note that your follower may not be teleporting with you if you were mounted, IT IS NOT AN ISSUE tho your companion will come back after a while (specially if you transition to doors etc) 3 - Once their AI kicks in followers are rather slow (they walk) to catch their horse ( just go.. they will catch up ). 4 - The AI will not enter combat unless you dismount and so the normal behavior starts. 5 - If your followe

Bash: Mkvirtualenv: Command Not Found

Answer : Solution 1 : For some reason, virtualenvwrapper.sh installed in /usr/bin/virtualenvwrapper.sh , instead of under /usr/local/bin . The following in my .bash_profile works... source "/usr/bin/virtualenvwrapper.sh" export WORKON_HOME="/opt/virtual_env/" My install seems to work fine without sourcing virtualenvwrapper_bashrc Solution 2 : Alternatively as mentioned below, you could leverage the chance that virtualenvwrapper.sh is already in your shell's PATH and just issue a source `which virtualenvwrapper.sh` Try: source `which virtualenvwrapper.sh` The backticks are command substitution - they take whatever the program prints out and put it in the expression. In this case "which" checks the $PATH to find virtualenvwrapper.sh and outputs the path to it. The script is then read by the shell via 'source'. If you want this to happen every time you restart your shell, it's probably better to grab the output from t

Add Request.GET Variable Using Django.shortcuts.redirect

Answer : Since redirect just returns an HttpResponseRedirect object, you could just alter that: response = redirect('url-name', x) response['Location'] += '?your=querystring' return response Is possible to add GET variables in a redirect ? (Without having to modifiy my urls.py) I don't know of any way to do this without modifying the urls.py . I don't have complains using HttpResponseRedirect('/my_long_url/%s/?q=something', x) instead, but just wondering... You might want to write a thin wrapper to make this easier. Say, custom_redirect def custom_redirect(url_name, *args, **kwargs): from django.core.urlresolvers import reverse import urllib url = reverse(url_name, args = args) params = urllib.urlencode(kwargs) return HttpResponseRedirect(url + "?%s" % params) This can then be called from your views. For e.g. return custom_redirect('url-name', x, q = 'something') # Should

Apple - Can You Force A Mobile Site On Your IPhone To Show Full Desktop View?

Image
Answer : I don't think you can do this in Safari on the iPhone but you could use a 3rd party browser app. Many of those will let you set the browser agent. One browser I know does this is 'Atomic Web Browser'. This may not work in all cases as some websites may use other ways of determining which content to show, for example, some will detect the screen dimensions. I've tried this on my iPhone with Atomic Web Browser. Within the browser, I went to settings, 'Identify browser as' and selected 'Safari Desktop'. Then I went to nascar.com and tapped on the nascar logo. It showed me the desktop version of the page. I checked in mobile safari and doing the same indeed took me to a mobile version. An additional recommendation: the free Puffin browser in the App Store displays full websites. Google Chrome for iPhone is my daily driver for Stackexchange and it works wonderfully well both in desktop and mobile modes. Tap the menu button Reqest Desk

Add User To Channel Automatically When User Asks

Answer : The bot ability is limited. It can only send and receive messages in a chat conversation and collect some information about other chat participants. It can not start a new conversation or other client functionality. For automate your task, you should use telegram API. There are some clients such as telegram-cli that use the telegram api and have high level methods. Other clients: tgl (C) kotlogram (Java) telethon (Python) webogram (Web) MadelineProto (PHP) TLSharp (C#) pytg (Python wrapper for telegram-cli) You can invite other users to your channel using: channels.inviteToChannel#199f3a6c channel:InputChannel users:Vector<InputUser> = Updates; You can invite several uses at a time, via a list (Vector) of InputUser. This seems consistent with Telegram Desktop and the mobile clients, which allows you to select multiple contacts and add them to your group. InputUser is of the form: inputUser#d8292816 user_id:int access_hash:long = InputUser;

Backtick Character Code Example

Example 1: backtick # A backtick ` Example 2: ` Alternatively known as acute, backtick, left quote, or an open quote, the back quote or backquote is a punctuation mark (`).

Bootstrap 4 Uppercase Code Example

Example 1: uppercase bootstrap class < p class = " text-lowercase " > Lowercased text. </ p > < p class = " text-uppercase " > Uppercased text. </ p > < p class = " text-capitalize " > CapiTaliZed text. </ p > Example 2: bootstrap 4 text-uppercase bootstrap 4 text-uppercase Example 3: bootstrap 4 font bold font-weight-bold Example 4: bootstrap uppercase < p class = " text-uppercase " > Uppercased text. </ p > Example 5: bootstrap text capitalize < p class = " text-capitalize " > CapiTaliZed text. </ p >

Boto3 Dynamodb Update Item Code Example

Example: get item dynamodb boto3 def get_movie(title, year, dynamodb=None): if not dynamodb: dynamodb = boto3.resource('dynamodb', endpoint_url="http://localhost:8000") table = dynamodb.Table('Movies') try: response = table.get_item(Key={'year': year, 'title': title}) except ClientError as e: print(e.response['Error']['Message']) else: return response['Item']

Check Lexicographical Order Python Code Example

Example 1: lexicographic order python my_arr = [ "hello" , "apple" , "actor" , "people" , "dog" ] print ( my_arr ) my_arr . sort ( ) print ( my_arr ) Example 2: lexicographic order python my_arr = [ "hello" , "apple" , "actor" , "people" , "dog" ] print ( my_arr ) # Create a new array using the sorted method new_arr = sorted ( my_arr ) print ( new_arr ) # This time, my_arr won't change in place, rather, it'll be sorted # and a new instance will be assigned to new_arr print ( my_arr )

Center A Position:fixed Element

Answer : You basically need to set top and left to 50% to center the left-top corner of the div. You also need to set the margin-top and margin-left to the negative half of the div's height and width to shift the center towards the middle of the div. Thus, provided a <!DOCTYPE html> (standards mode), this should do: position: fixed; width: 500px; height: 200px; top: 50%; left: 50%; margin-top: -100px; /* Negative half of height. */ margin-left: -250px; /* Negative half of width. */ Or, if you don't care about centering vertically and old browsers such as IE6/7, then you can instead also add left: 0 and right: 0 to the element having a margin-left and margin-right of auto , so that the fixed positioned element having a fixed width knows where its left and right offsets start. In your case thus: position: fixed; width: 500px; height: 200px; margin: 5% auto; /* Will not center vertically and won't work in IE6/7. */ left: 0; right: 0; Again, this wo

How To Download Youtube Mp3 Converter Code Example

Example 1: youtube mp3 converter You can use WebTools , it's an addon that gather the most useful and basic tools such as a synonym dictionary , a dictionary , a translator , a youtube convertor , a speedtest and many others ( there are ten of them ) . You can access them in two clics , without having to open a new tab and without having to search for them ! - Chrome Link : https : //chrome.google.com/webstore/detail/webtools/ejnboneedfadhjddmbckhflmpnlcomge/ Firefox link : https : //addons.mozilla.org/fr/firefox/addon/webtools/ Example 2: youtube download mp3 I use https : //github.com/ytdl-org/youtube-dl/ as a Python CLI tool to download videos

Cobol Hello World Example

Example: hello world in cobol $ vim helloworld IDENTIFICATION DIVISION. PROGRAM-ID. HELLO-WORLD. * simple hello world program PROCEDURE DIVISION. DISPLAY 'Hello world!' . STOP RUN.

Can I Play Kerbal Without Steam?

Answer : Can I play Kerbal without Steam? Yes, to answer the question in your title. Do I need Steam for Kerbal? No, to answer the question in your post. Steam is not required for KSP. When you purchase it from the Kerbal Space Program store, you either buy a Steam Key, or buy it so that you download / patch it from their servers. This is a choice you only get to make once. Just click on "Add to Cart" rather than "Buy a Steam Key" and you can continue your blissful Valve-free rocket experiences.

Cleanup After All Junit Tests

Answer : I'm using JUnit 4.9. Will this help?: import junit.framework.TestCase; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({First.class,Second.class,Third.class}) public class RunTestSuite extends TestCase { @BeforeClass public static void doYourOneTimeSetup() { ... } @AfterClass public static void doYourOneTimeTeardown() { ... } } Edit: I am quite positive (unless I misunderstand your question) that my solution is what you are looking for. i.e. one teardown method after all your tests have ran. No listener required, JUnit has this facility. Thanks. I recommend to use org.junit.runner.notification.RunListener, example: public class TestListener extends RunListener { @Override public void testRunStarted(Description description) throws Exception { // Called be

ASP.NET MVC3 - Textarea With @Html.EditorFor

Answer : You could use the [DataType] attribute on your view model like this: public class MyViewModel { [DataType(DataType.MultilineText)] public string Text { get; set; } } and then you could have a controller: public class HomeController : Controller { public ActionResult Index() { return View(new MyViewModel()); } } and a view which does what you want: @model AppName.Models.MyViewModel @using (Html.BeginForm()) { @Html.EditorFor(x => x.Text) <input type="submit" value="OK" /> } Someone asked about adding attributes (specifically, 'rows' and 'cols'). If you're using Razor, you could just do this: @Html.TextAreaFor(model => model.Text, new { cols = 35, @rows = 3 }) That works for me. The '@' is used to escape keywords so they are treated as variables/properties. @Html.TextAreaFor(model => model.Text)

Ascii Color Codes Python Code Example

Example 1: print colored text python def colored ( r, g, b, text ) : return " \033 [38;2;{};{};{}m{} \033 [38;2;255;255;255m" .format ( r, g, b, text ) text = 'Hello, World' colored_text = colored ( 255 , 0 , 0 , text ) print ( colored_text ) #or print ( colored ( 255 , 0 , 0 , 'Hello, World' )) Example 2: ansi colors Black \ e [ 0 ; 30m Blue \ e [ 0 ; 34m Green \ e [ 0 ; 32m Cyan \ e [ 0 ; 36m Red \ e [ 0 ; 31m Purple \ e [ 0 ; 35m Brown \ e [ 0 ; 33m Gray \ e [ 0 ; 37m Dark Gray \ e [ 1 ; 30m Light Blue \ e [ 1 ; 34m Light Green \ e [ 1 ; 32m Light Cyan \ e [ 1 ; 36m Light Red \ e [ 1 ; 31m Light Purple \ e [ 1 ; 35m Yellow \ e [ 1 ; 33m White \ e [ 1 ; 37m Example 3: python ansi escape sequences color collection class colors: reset = " \033 [0m" # Black fgBlack

Change String To Integer Javascript Code Example

Example 1: how to convert string to int js let string = "1" ; let num = parseInt ( string ) ; //num will equal 1 as a int Example 2: string to int javascript var text = '42px' ; var integer = parseInt ( text , 10 ) ; // returns 42 let myNumber = Number ( "5.25" ) ; //5.25 Example 3: string to int javascript var text = '42px' ; var integer = parseInt ( text , 10 ) ; // returns 42 Example 4: string to int javascript var text = '3.14someRandomStuff' ; var pointNum = parseFloat ( text ) ; // returns 3.14 Example 5: string to int js string to int js

Array Indexof Js Code Example

Example 1: javascript indexof // indexOf getting index of array element , returns - 1 if not found var colors = [ "red" , "green" , "blue" ] ; var pos = colors . indexOf ( "blue" ) ; // 2 // indexOf getting index of sub string , returns - 1 if not found var str = "We got a poop cleanup on isle 4." ; var strPos = str . indexOf ( "poop" ) ; // 9 Example 2: js get index of item in array array . indexOf ( "item" ) ; Example 3: js array get index var fruits = [ "Banana" , "Orange" , "Apple" , "Mango" ] ; return fruits . indexOf ( "Apple" ) ; // Returns 2 Example 4: javasript array indexof var array = [ 2 , 9 , 9 ] ; array . indexOf ( 2 ) ; // 0 array . indexOf ( 7 ) ; // - 1 array . indexOf ( 9 , 2 ) ; // 2 array . indexOf ( 2 , - 1 ) ; // - 1 array . indexOf ( 2 , - 3 ) ; // 0 Example 5: how to get the index

Cpp Shell Online Code Example

Example: c++ online compiler This two are good C ++ compilers : https : //www.onlinegdb.com/online_c++_compiler https : //www.programiz.com/cpp-programming/online-compiler/