Skip to content

Instantly share code, notes, and snippets.

View ChengLuFred's full-sized avatar

Cheng ChengLuFred

  • Stevens Institute of Technology
  • Hoboken
View GitHub Profile
@ChengLuFred
ChengLuFred / package_management.md
Last active October 25, 2020 22:46
[Package Management in Python] smart way to import modules #Python

Import module from different file

import file_name as fn

or

from file_name import *
@ChengLuFred
ChengLuFred / operaters.md
Created September 16, 2020 03:17
[Operators in R] #R
%in%
@ChengLuFred
ChengLuFred / flow_chart.md
Last active July 15, 2020 02:37
[Graph in Latex] #Latex

0 Package

\usepackage{tikz}                               % package Tikz for flow chart
\usetikzlibrary{shapes.geometric, arrows}       % package Tikz for flow chart

1 Defination of Node in Flow Chart

To begin with, we need define some nodes with specific shape and attributes.

@ChengLuFred
ChengLuFred / dataframe.md
Last active October 4, 2020 01:12
[Data Process] #Python

0 Package

import pandas as pd

1 Index and locating

create multiple index and locate data according to multi-level index

@ChengLuFred
ChengLuFred / re.md
Last active June 25, 2020 00:53
[Regular Expression] split text according to requirement #Python

Use re(regular expression) to split text

re.split('\W+|_',x)

We use | to seperate symbols that we want to use as spliter. Here \W+ means words. An example is following,

>>>text = 'I:\\Textual Analysis Data\\19950131_10-K_edgar_data_69970_0000950152-95-000069_1.txt'
>>>re.split('\W+',text)
['I',
@ChengLuFred
ChengLuFred / cheat_sheet.md
Last active June 23, 2020 17:30
[Cheat Sheet for WSL] often used option #cmd
  • switch between WSL(Ubuntu) and CMD(Windows)
$ cmd.exe # to change to windows cmd
$ wsl.exe # to change to wsl ubuntu terminal
@ChengLuFred
ChengLuFred / cheat sheet.md
Last active January 14, 2024 05:42
[Markdown Cheat Sheet] #Markdown
  1. Markdown markdown

  2. R markdown rmarkdown

@ChengLuFred
ChengLuFred / **kwarg.md
Last active June 21, 2020 03:22
[Pass variable number of parameters] #Python

*args pass a list of values or variables

**kwarg(key words arguments) pass a dictionary

def test_args_kwargs(arg1, arg2, arg3):
    print("arg1:", arg1)
    print("arg2:", arg2)
    print("arg3:", arg3)

# test *args
@ChengLuFred
ChengLuFred / cheat sheet.md
Last active June 21, 2020 02:30
[Math Syntax in Latex] #Latex
<object data="http://yoursite.com/the.pdf" type="application/pdf" width="700px" height="700px">
    <embed src="http://yoursite.com/the.pdf">
        <p>This browser does not support PDFs. Please download the PDF to view it: <a href="http://yoursite.com/the.pdf">Download PDF</a>.</p>
    </embed>
@ChengLuFred
ChengLuFred / file_manage_python.md
Last active December 1, 2020 19:54
[File Management in Python]file combine, zip extract, etc. #Python

1. Quick way to read file using pandas

file_name = 'file_name.csv'
tickers_info = pd.read_csv(file_name,
                           sep = ",",			 # ',' for csv file and '\t' for text file
						   header = 0,			 # row number used as head
                           usecols=[1, 2], 		 # column index to be included
                           index_col = [0], 	 # column index which apdated above
 engine='c') # c engine is faster than python