wordpress tips

questions   methods
how to embed content from another site? install iframe plug in, then insert input content like 

 tips: quick edit widgets    under ‘customize’ state, hover mouse to the place you want to edit, shift-click
how to add personal customized menu   go to ‘Dashboard’->’Appearance’->’customize’ -> ‘menus’ -> add new menu
 how to add internal link?       highlight words and insert link (Ctrl + K), type in content from your own site and apply              
 how to add read more?    insert read more tag (shift+alt+t) into your article


useful wordpress plugins

plugins function 
  • AddToAny Share Buttons
       create share bars contains social medias & create follow me bars
  • Custom Meta Widget
can choose and disable contents in Meta widget
  • DrawIt (draw.io)

Draw and edit flow charts, diagrams, images and more while editing a post.

  • Insert HTML Snippet
Add HTML code to your pages and posts easily using shortcodes
  • Live Composer
Front-end page builder for WordPress with drag and drop editing. Visually customize any page element.
  • Profile Widget Ninja
profile display widget plugin with pic and social media icons
  • Subtitles
add subtitles
  • TinyMCE Color Grid
add more colors while editing
  • TinyMCE Pre Button
add <pre> button
  • WP Downgrade
to either downgrade or update WordPress Core to an arbitrary version of your choice.
  • WP Edit
great content Editing
  • Crayon Syntax Highlighter
highlight codes for various languages
  • WordPress Mobile Pack
convert phone viewers into app viewing 
  • WP Statistics
visiting stat
  • Display Widgets
hide widgets for specific categories, pages, etc

Pandas basis


Question  answer explain
 how to get how big in memory a DataFrame object is?  df.info()
 what is the best representative of null value in Pandas object?  np.nan import numpy as np
 what is the best way to slice a DataFrame by index?  df.iloc[-5:, 2:] use iloc method
 how to convert a DataFrame (excluding indexes) to a numpy ndarray?  df.values it is a attribute, can’t be called
 what is the most basic way to create a DataFrame?  pd.DataFrame(dict) pass dictionary to; keys are column names
 what is broadcasting?  pd[‘new’]=7 all the values of the new column will be 7
 how to change df’s column names, index names?  pd.columns = [‘a’,’b’,…]

pd.index = [‘c’,’d’,…]

assign value directly
 when read csv, how to specify names of the column  pd.read_csv(path, names=[‘a’,’b’,…..])  instead, pass header=None will prevent pandas using data as column names, but use 0,1,2,3 ….
when read csv, how to let pandas to turn some specific values into NaN? pd.read_csv(path, na_values = ‘-1’)

pdf.read_csv(path, na_values = {‘column3’:[‘ -2’, ‘wtf’,…]})

all the values which is character ‘-1’ will be rendered to NaN
how to parse data in reading csv pd.read_csv(path, parse_dates = [[0,1,2]]) pandas will parse column 1, 2, 3 into one datetype column
does index of df have a name? pd.index.name = ‘xxx’ assign a name to the index of df
how to save df to a csv file with other delimiters  rather than ‘,’ pd.to_csv(path, sep=’\t’) save to a csv file which separates data by tab

how to batch convert string to Date type


how to get 2 DataFrame together,  & append one df to another?

git command

Git task Notes Git commands
Tell Git who you are Configure the author name and email address to be used with your commits.

Note that Git strips some characters (for example trailing periods) from user.name.

git config --global user.name "Sam Smith"

git config --global user.email sam@example.com

Create a new local repository git init
Check out a repository Create a working copy of a local repository: git clone /path/to/repository
For a remote server, use: git clone username@host:/path/to/repository
Add files Add one or more files to staging (index): git add filename
Commit Commit changes to head (but not yet to the remote repository): git commit -m "Commit message"
Commit any files you’ve added with git add, and also commit any files you’ve changed since then: git commit -a
Push Send changes to the master branch of your remote repository: git push origin master
Status List the files you’ve changed and those you still need to add or commit: git status
Connect to a remote repository If you haven’t connected your local repository to a remote server, add the server to be able to push to it: git remote add origin <server>
List all currently configured remote repositories: git remote -v
Branches Create a new branch and switch to it: git checkout -b <branchname>
Switch from one branch to another: git checkout <branchname>
List all the branches in your repo, and also tell you what branch you’re currently in: git branch
Delete the feature branch: git branch -d <branchname>
Push the branch to your remote repository, so others can use it: git push origin <branchname>
Push all branches to your remote repository: git push --all origin
Delete a branch on your remote repository: git push origin :<branchname>
Update from the remote repository


Fetch and merge changes on the remote server to your working directory: git pull
To merge a different branch into your active branch: git merge <branchname>
View all the merge conflicts:

View the conflicts against the base file:

Preview changes, before merging:

git diff

git diff --base <filename>

git diff <sourcebranch> <targetbranch>

After you have manually resolved any conflicts, you mark the changed file: git add <filename>
Tags You can use tagging to mark a significant changeset, such as a release: git tag 1.0.0 <commitID>
CommitId is the leading characters of the changeset ID, up to 10, but must be unique. Get the ID using: git log
Push all tags to remote repository: git push --tags origin
Undo local changes If you mess up, you can replace the changes in your working tree with the last content in head:

Changes already added to the index, as well as new files, will be kept.

git checkout -- <filename>
Instead, to drop all your local changes and commits, fetch the latest history from the server and point your local master branch at it, do this: git fetch origin

git reset --hard origin/master

Search Search the working directory for foo(): git grep "foo()"

excel shortcuts 1

excel basics

1upper  right cornerribbon display options
2upper left cornerquick access bar can choose show below the ribbon
3undo/ redoCtrl + Z/ Ctrl + Y in other platform --redo : Ctrl+ Shift + Z
4fix column width for double clickHome -> Wrap Text
5switch sheetsCtrl + Page up/down
6bold/italic/underlineCtrl + B/I/U
7find/replaceCtrl + F/H
8texts are left aligned / numbers are right aligned
9insert comment to a cellShift + F2
10show all commentsReview -> show all comments
11save as F12
12count non-empty cells =COUNTA(selected cells)
13count numbers alone =COUNT(selected cells)
14find second largest NO. =large(cells, 2)
15all column/ rows to same widthselect all target columns/ rows -> drag any edges
16"Enter" within a cell
new paragraph
Alt + Enter
17format cellCtrl + 1
Ctrl + Shift + F
18convert to tableCtrl + T
19slicer have table already
insert slicer
20keep ratio of inserted shapeshold Shift
21print with titles (columns /rows)page layout -> print titles
22page break previewbottom right corner
23print area selectionpage layout -> print area
24create a chart in a new sheetselect data then press F11
25create chart in the same sheetselect data then Alt + F1design tab
26sparklinesquick analysis -> sparklines
insert -> sparklines
27divide sheet by rowsgo to column one -> splitdouble click to cancel
28divide sheet by columnsgo to row one -> split
29only see summary of large datadata -> group-> auto outline
30hide/create outline symbolCtrl + 8
31create a new sheet on the leftShift + F11
32if func return string values must be quoted by double quote "string"
33vlookup for approx match,
input table
value must be ascending order
34 =function, auto completeTab
35vlookup default value is 1 approx matchthe fourth para set to 0 to exact match
36 =countif() =countif() =sumif() =averageif()
37format cell -> protectionReview -> show all comments
38when save add passwdsave as -> tools -> general options
39track changesReview -> track changes
40sortdata -> sort
41subtotal data -> subtotal
42Only select visible data
(before copy, or etc)
Alt + ;
43Refresh (for pivot table)Alt + F5
44pivot table see detailsdouble click
45pivot chartsinsert -> pivot chart
pivot table Alt+F1
46what if analysisdata -> what if analysis ->
goal seek
47solverdata -> solver
options -> add-ins
48scenario what-if analysis -> scenario manager
49sensitivity analysiswhat-if analysis -> data table
50strike throughCtrl + 5
51select(highlight) cells with formulashome -> find and select -> formulas
52Macrosview -> Macros -> record
and set shortcut
53select(highlight) cells only contains numbers/ text/ othershome -> find and select -> go to special
54stop recording Macrobottom left corner stop
55assign Macro to a button(shape, icons, pictures, etc)right click shape -> assign macro
56repeat last one actionAlt + Enter
57redoCtrl + Y
or F4

multiple worksheets/workbooks managing

description  shortcuts
insert hyperlink to a cellCtrl + K
mouse to lower left cornerCtrl+left clickScroll to the first/ last sheet
show how many sheets the workbook havemouse to lower left corner, right click
go to the first row of one columndouble click the top edge of any cell of that columnCtrl + up arrow
switch worksheetsCtrl + page up/ page down
go the first cell of the sheetupper left cornerCtrl + Home
jump to the last cell of this work sheetCtrl + End
go to the end of one columnleft /right is the samedouble click the bottom edge of any cell of that columnCtrl + down arrow
move one screen to the right/ leftfor ultra wide sheetsAlt + page down/
Alt + page up
if hold arrow will go to the very end
insert rowsgo the left most row number --> right click --> insert
merge cellsHome -> merge
wrap cellsHome -> Wrap text
add new sheets to the left of the current sheetselect current sheet and press
Shift + F11
add new sheets to the right of the current sheetselect current sheet -> right click the '+' icon on the right
group select multiple sheetscan then right click to insert contentson the bottom -> Shift + left click sheets
Ctrl + any single sheet
create a copy sheetselect sheet Ctrl + Drag to target position ;
right click sheet -> move or copy
color sheetright click sheet -> Tab color
unhide hidden rows / columnsright click rows / columns -> unhide

or double click row/column's edge
select all -> upper left triangle ->

or select certain rows / columns
sheets can be hide/ unhideright click sheet/sheets
lock workbook manipulationReview -> Protect Workbook
if open multiple workbooks (windows), arrange positions(view -> New window)
view -> Arrange all (current window will be the main)
hide ribbon double click current ribbon
switch windowview -> switch window
open the same workbook in a new windowchange any of the two will change allview -> new window
mouse drag/ copymove: select -> drag
copy: select-> Ctrl+drag
move/ drag to another worksheet or self worksheet in new windfast drag selected data to another window
Insert row/ column
mouse +
make change to multiple sheetsselect (group) multiple sheets, then make changes
best fit space of multiple columns /rowsselect columns/ rows first, then double chick any edges
(if grouped will change all)
copy interactive data/ formula/ results to another sheet/placecopy then go to destination, right click ->paste special -?> paste link
then drag e.g. right, that cell will be mapped to the original worksheetcan combine with double click + F4
absolute address
reference to another sheet!ERROR! illegal character '!'
show formula (content after '=')put a space before =
create formula
string concat
!ERROR! illegal character '&'cellref reference the cell with value of the name of destination worksheetuse & to paste cellref to string

string must be quoted with double quote "string"
display formula in another cell single cell, select, F2Ctrl + `
or formuls -> show formulas
!ERROR! undefined variable 'formulatext'
manipulate multiple sheets. sum(one cell from a sheet for 100 sheets)"3D" formulaformula ->autosum
within =sum()
sheet selection, first sheet, then Ctrl chick right arrow will go to the last sheet, Shift click
do not want to move the active cell but comfirmCtrl + Enter
Consolidate Data -> Consolidate
grand total select cells with blank edges
Alt + =
or formulas -> autosum
input value to multiple cells at once select multiple cells, input value-> Ctrl + Enter
pivot table wizard or quick access toolbar
customize toolbar
more comments
Alt+ D then P
multiple consolidation ranges
with pivot tabledesign tab
navigate multiple workbooksview -> switch windows
add anything to quick access toolbarright click target button, add to quick access toolbar
navigate tabs to the rightCtrl+F6Ctrl+Tab
navigate tabs to the leftCtrl+Shift+F6Ctrl+Shift+Tab
open a new workbookCtrl+N
close all open fileshold Shift and mouse right click upper right 'X'
fill multiple selected cells with formulafrom formula cell, Shift arrow select cell, then Ctrl+ D/ Ctrl + Rfrom formula cell, Shift arrow select cells, press F2 go back to formula cell, then Ctrl+ Enter
paste specialCtrl + Alt + E
or Alt + E + S
format cellsCtrl + Shift + F
exam data link from other workbookdata -> edit links
select all sheets and findbottom left corner, right click any sheet -> select all sheets, then upper left corner right click select all cells, then Ctrl + F (Home -> Find & select)
if linkage to another workbook, formula contains '['
pivot table insert pivot table
clear content delete


Plot with Seaborn

Statistical Plotting with Seaborn

In [1]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline

load a dataset online from seaborn

In [2]:
In [3]:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 244 entries, 0 to 243
Data columns (total 7 columns):
total_bill    244 non-null float64
tip           244 non-null float64
sex           244 non-null category
smoker        244 non-null category
day           244 non-null category
time          244 non-null category
size          244 non-null int64
dtypes: category(4), float64(2), int64(1)
memory usage: 6.8 KB
In [4]:
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3

visualizing regressions

  • Plot data and regression model fits across a FacetGrid.
In [5]:
<seaborn.axisgrid.FacetGrid at 0x7f71804eb950>

group by categorical column

In [6]:
sns.lmplot(x='total_bill',y='tip',data=tip, size=3,
<seaborn.axisgrid.FacetGrid at 0x7f717db077d0>

plot group data in the same graph

In [7]:
sns.lmplot(x='total_bill',y='tip',data=tip, size=3, aspect=2,
          hue='sex', palette='Set1')
<seaborn.axisgrid.FacetGrid at 0x7f71804eba90>

plot Residuals

  • residplot()
In [8]:
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
In [9]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f717cf9e7d0>

Higher-order regressions

  • When there are more complex relationships between two variables, a simple first order regression is often not sufficient to accurately capture the relationship between the variables. Seaborn makes it simple to compute and visualize regressions of varying orders.

  • sns.regplot()

  • the function sns.lmplot() is a higher-level interface to sns.regplot().

    • A principal difference between sns.lmplot() and sns.regplot() is the way in which matplotlib options are passed (sns.regplot() is more permissive).

    • For both sns.lmplot() and sns.regplot(), the keyword order is used to control the order of polynomial regression.

    • The function sns.regplot() uses the argument scatter=None to prevent plotting the scatter plot points again.

In [10]:
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
In [11]:
# Generate a scatter plot of 'weight' and 'mpg' using red circles
plt.scatter(tip['total_bill'], tip['tip'], label='data', color='red', marker='o', alpha=.5)

# Plot in blue a linear regression of order 1 between 'weight' and 'mpg'
sns.regplot(x='total_bill', y='tip', data=tip, scatter=None, color='blue', label='order 1')

# Plot in green a linear regression of order 2 between 'weight' and 'mpg'
sns.regplot(x='total_bill', y='tip', data=tip, scatter=None, order=2, color='green', label='order 2')

sns.regplot(x='total_bill', y='tip', data=tip, scatter=None, order=3, color='purple', label='order 2')

# Add a legend and display the plot
plt.legend(loc='upper right')

Visualizing univariate distributions

Strip plot


In [12]:
sns.stripplot(y= 'tip', data=tip)
plt.ylabel('tip ($)')
<matplotlib.text.Text at 0x7f717ce6aa50>
In [13]:
sns.stripplot(x='day', y='tip', data=tip)
plt.ylabel('tip ($)')
<matplotlib.text.Text at 0x7f717ce22710>
In [14]:
sns.stripplot(x='day', y='tip', data=tip, size=4, jitter=True)
plt.ylabel('tip ($)')
<matplotlib.text.Text at 0x7f717cc93750>
In [15]:
sns.swarmplot(x='day', y='tip', data=tip)
plt.ylabel('tip ($)')
<matplotlib.text.Text at 0x7f717cca2ad0>
In [16]:
sns.swarmplot(x='day', y='tip', data=tip, hue='sex',  palette='Set1')
plt.ylabel('tip ($)')
<matplotlib.text.Text at 0x7f717cb27350>
In [17]:
sns.swarmplot(x='tip', y='day', data=tip, hue='sex',  orient='h')
plt.ylabel('tip ($)')
<matplotlib.text.Text at 0x7f717ca7a690>

Violin plot

In [18]:
sns.boxplot(x='day', y='tip', data=tip)
plt.ylabel('tip ($)')

sns.violinplot(x='day', y='tip', data=tip)
plt.ylabel('tip ($)')
In [19]:
sns.violinplot(x='day', y='tip', data=tip, inner=None,

sns.stripplot(x='day', y='tip', data=tip, size=4,

plt.ylabel('tip ($)')
<matplotlib.text.Text at 0x7f717ca25dd0>

Visualizing multivariate distributions

Joint plots

In [20]:
sns.jointplot(x= 'total_bill', y= 'tip', data=tip, size=5)
<seaborn.axisgrid.JointGrid at 0x7f717ca34a10>

Using kde=True

  • kernal density distribution
In [21]:
sns.jointplot(x='total_bill', y= 'tip', data=tip,
              kind='kde', size=5)
<seaborn.axisgrid.JointGrid at 0x7f717ce8b050>

Pair plot

In [22]:
sns.pairplot(tip, size=2)
<seaborn.axisgrid.PairGrid at 0x7f717c398c50>
In [23]:
sns.pairplot(tip, hue='sex', kind='reg')
<seaborn.axisgrid.PairGrid at 0x7f717b9e4b10>