Pandas df.size, df.shape and df.ndim

# importing pandas module 
import pandas as pd 
  
# making data frame 
data = pd.read_csv("https://media.geeksforgeeks.org/wp-content/uploads/nba.csv") 
  
# dataframe.size 
size = data.size 
  
# dataframe.shape 
shape = data.shape 
  
# dataframe.ndim 
df_ndim = data.ndim 
  
# series.ndim 
series_ndim = data["Salary"].ndim 
  
# printing size and shape 
print("Size = {}\nShape ={}\nShape[0] x Shape[1] = {}". 
format(size, shape, shape[0]*shape[1])) 
  
# printing ndim 
print("ndim of dataframe = {}\nndim of series ={}". 
format(df_ndim, series_ndim))
Size = 4122
Shape=(458, 9)
Shape[0] x Shape[1] = 4122
ndim of dataframe = 2
ndim of series=1

References
https://www.geeksforgeeks.org/python-pandas-df-size-df-shape-and-df-ndim/

Iterate over rows in a DataFrame in Pandas

# import pandas package as pd 
import pandas as pd 
  
# Define a dictionary containing students data 
data = {'Name': ['Ankit', 'Amit', 'Aishwarya', 'Priyanka'], 
                'Age': [21, 19, 20, 18], 
                'Stream': ['Math', 'Commerce', 'Arts', 'Biology'], 
                'Percentage': [88, 92, 95, 70]} 
  
# Convert the dictionary into DataFrame 
df = pd.DataFrame(data, columns = ['Name', 'Age', 'Stream', 'Percentage']) 
  
print("Given Dataframe :\n", df) 
  
print("\nIterating over rows using iterrows() method :\n") 
  
# iterate through each row and select  
# 'Name' and 'Age' column respectively. 
for index, row in df.iterrows(): 
    print (row["Name"], row["Age"])

References
https://www.geeksforgeeks.org/different-ways-to-iterate-over-rows-in-pandas-dataframe/

Scroll to Top using Javascript

window.scroll({
  top: 100,
  left: 100,
  behavior: 'smooth'
});
var elmnt = document.getElementById("content");
elmnt.scrollIntoView();
var elmnt = document.getElementById("myDIV");
var x = elmnt.scrollLeft;
var y = elmnt.scrollTop;

References
https://developer.mozilla.org/en-US/docs/Web/API/Window/scroll
https://www.w3schools.com/jsref/met_element_scrollintoview.asp
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView
https://www.w3schools.com/jsref/prop_element_scrolltop.asp
https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop

Access to HTML element using @ViewChild in Angular

<textarea  #someVar  id="tasknote"
                  name="tasknote"
                  [(ngModel)]="taskNote"
                  placeholder="{{ notePlaceholder }}"
                  style="background-color: pink"
                  (blur)="updateNote() ; noteEditMode = false " (click)="noteEditMode = false"> {{ todo.note }} 

</textarea>
import {ElementRef,Renderer2} from '@angular/core';
@ViewChild('someVar') el:ElementRef;

constructor(private rd: Renderer2) {}

ngAfterViewInit() {
      console.log(this.rd); 
      this.el.nativeElement.focus();      // we can access it after ngAfterViewInit
}

References
https://stackoverflow.com/questions/38944725/how-to-get-dom-element-in-angular-2

TortoiseGit – Revert vs Reset vs Checkout

If you deleted a few files and you have not made a commit yet, Revert will work just fine. Selecting TortoiseGit -> Revert… will display a window for you to select the files you want restored. Deleted files will show in red.

If you already committed the delete, then you can Reset to a commit before you deleted the files. Be warned that if you use reset, you will no longer see in your log the commit(s) after the commit you reset to.

If you want to preserve in your log the commit that deleted the files, you can Checkout the commit before the delete into a new branch, copy the restored files into a separate folder, switch back to your original branch, then add the files back to your original branch.

References
https://stackoverflow.com/questions/1335644/tortoisegit-revert

Detecting when user stopped scrolling

We want to listen for scroll events using addEventListener. We’ll set a delayed timeout function to run a few milliseconds after the event, but with each scroll event we’ll clear that timeout function so it doesn’t run.

When scrolling has stopped, the delayed function doesn’t get cleared and runs.

// Setup isScrolling variable
var isScrolling;

// Listen for scroll events
window.addEventListener('scroll', function ( event ) {

  // Clear our timeout throughout the scroll
  window.clearTimeout( isScrolling );

  // Set a timeout to run after scrolling ends
  isScrolling = setTimeout(function() {

    // Run the callback
    console.log( 'Scrolling has stopped.' );

  }, 66);

}, false);

References
https://gomakethings.com/detecting-when-a-visitor-has-stopped-scrolling-with-vanilla-javascript/