3 Flashcards
VC: The most senior person in a VC firm is called a
managing director or general partner.
VC: The managing director or general partner
make the final decision on which companies to invest in and sit on the board of directors for the companies they invest in.
HostGator: To allow remote sql connections
Click “Remote MySQL” and enter the IP address of the computer you want to allow.
HostGator: To create a database, a new user, and give permissions
click “MySQL Database Wizard” and go through it.
HostGator: To upload a csv
Click on desired db, then click on import tab. Select the csv. Choose the csv file format, then if necessary, click checkbutton for “first line contains table columns”
DB: A simple DB is called
sqlite
Windows: To create a new file, type
echo.>file_name.py
Windows: To see current directory, type
echo %cd%
Windows: To change directory, type
cd c:/users/alen.solomon/desktop
Windows: To list all the files in current directory, type
dir /b
Pandas: Non printable characters can cause a “ValueError: No columns to parse from file” and can be fixed by
adding the parameter encoding=”utf-16” to read_csv
Adwords: When exporting a report from adwords, make sure not to use
Excel.csv format
Pandas: To choose a delimiter for read_csv, type
sep=”\t”
Pandas: To turn an excel file to a df, type
xl = pandas.ExcelFile("path/to.xlsx") df = xl.parse("Sheet name")
Pandas: To change column values with a dollar sign to a float, type
df[“Cost”] = df[“Cost”].apply(lambda x: str(x).strip(“$”)).astype(float)
Pandas: When you use df[“Column name”].apply(my_function)
the function name does not need to end with ()
Pandas: To return only certain columns of a df in a set order, type
df = df.ix[ :, [“Abbrev”,”Jan”,”Feb”,”Mar”,”Total”]]
Pandas: To replace all nans with something, type
df[“Column name”].fillna(“Replacement”, inplace=True)
Pandas: To write a couple dfs to two sheets in excel, type
writer = pandas.ExcelWriter(‘/users/student/desktop/demo.xlsx’, engine=’xlsxwriter’)
df. to_excel(writer, index=False, sheet_name=’Sheet1’)
df2. to_excel(writer, index=False, sheet_name=’Sheet2’)
writer. save()
Windows: To clear the cmd screen, type
CLS
Numpy: To turn a numpy array into a matrix, type
my_numpy_array.reshape(5,5)
Note: the dimensions are the 5,5
Numpy: To create a boolean index matrix from two numpy matrices, type
my_numpy_matrix
Numpy: To turn a numpy matrix back into an array, type
my_numpy_matrix.ravel()
Selenium: To import selenium, type
from selenium import webdriver
Selenium: To send selenium to a site, type
my_browser.get(“http://google.com”)
Selenium: To instantiate Chrome, type
my_browser = webdriver.Chrome()
Selenium: To return the title tag, type
my_browser.title
Selenium: To find an element on a page by it’s id, type
my_element = my_browser.find_element_by_id(“lst-ib”)
Selenium: To press keyboard into a page element, type
my_browser.find_element_by_name(“aw”).send_keys(“Send these keys”)
Selenium: To close the browser you instantiated, type
my_browser.quit()
Selenium: To submit in an element, type
my_element.submit()
Selenium: To simulate an arrow key press, type
my_element.send_keys(“my text”, Keys.ARROW_DOWN)
Selenium: To empty a text field, type
my_browser.find_element_by_id(“field”).clear()
Seleniun: To click a submit button, type
my_browser.find_element_by_id(“submit”).click()
Selenium: To select an element by its class name, type
my_browser.find_element_by_class_name(“date-box”)
HTML: The -select> tag is used for
Drop down menues
Selenium: To find the first form on a page through its xml path, type
my_browser.find_element_by_xpath(“//form[1]”)
Note: the slashes represent moving into the html tags and then the body tags and into the form tags.
Selenium: An easier way to find the submit form button and press it is
my_browser.find_element_by_id(“pswrd”).submit()
Selenium: To click a checkbox xpath, type
my_browser.find_element_by_xpath(“.//*[@id=’facebook’]/body/div[2]/label[2]”).click()
Note: Find xpath using firepath.
Selenium: The best way to find a checkbox is
xpath
Selenium: Sometimes to make an xpath work you need to
remove the [@id="js_5x"] from //*[@id="js_5x"]/div/ul/li[6]/a/span/span
Selenium: To get the xpath in chrome
Inspect element twice and then right click and click “copy xpath”
Selenium: When looking for the path for checkboxes or buttons, often
the label, or the outer ridge of button outside of the button text shows the correct path in inspect element rather than the button itself.
Selenium: When uploading a file do not
click on the upload button.
Selenium: To upload a file, type
my_browser.find_element_by_xpath(“//*/body/div[6]/input”).send_keys(“/users/student/desktop/report.csv”)
Selenium: To select an list item in a drop down menu, type
from selenium.webdriver.support.select import Select
select = Select(my_browser.find_element_by_id(“dropdownid”))
select.select_by_visible_text(“Jan”)
Selenium: To make the browser continue looking for a page element if it is not there for a set amount of time, type
my_browser.implicitly_wait(50)
Selenium: implicitly_wait(30) only has to be
set once and all tests for this browser will have the wait.
BS4: To parse a soup_page for an html tag with a certain parameter (e.g. css class name), type
soup_page.find_all(“div”, {“class”: “name”})
BS4: To return a list of all the top level html tags contents separated, type
soup_page.contents
BS4: To return the first item in a list of all the top level html tags contents separated, type
soup_page.contents[0]
BS4: To return the first item in a list of all the top level html tags contents separated and then the first tags contents from within that list item, type
soup_page.contents[0].contents[0]
Python: To use a list comprehension to return a boolean index, type
my_list = [1,2,3,4,5,6,7,8]
[item>3 for item in my_list]
IPYNB: To make a graph show up, type
%matplotlib inline
import matplotlib.pyplot as plt
df.plot(x=”Column”, y=”Column2”, kind=”scatter”)
Pandas: A series is like a
One dimensional array with an index.
Pandas: To set your own index to a Series or df, type
my_index_list = list(range(20)) my_series.index = my_index_list
Pandas: To slice a section of a Series by its index, type
my_series.ix[3:6]
Pandas: In order to set a new index for a df or Series, the index list must
Be the same length as the df or Series.
BS4: To put the page source of a selenium page into a soup_page, type
page = my_browser.page_source
soup_page = BeautifulSoup(page)
Pandas: To return the length and width of a df in a tuple, type
df.shape
Pandas: To see how many unique values are in a column, type
df[“column name”].unique()
Pandas: Even after you change the index to something other than 0 onward, it will
still allow you to slice by the index number
Pandas: To return specific indexes from a Series, type
my_series[[ 6, 9, 2]]
or
my_series[[ “A”, “C”, “G”]]
Pandas: If you change the index of a Series to new numbers you cannot use the original index of the numbers unless yo use
my_series.iloc[0: 5]
or
my_series.iloc[[4, 6, 9]]
Pandas: The difference between .iloc and .ix when the index is numerical, but doesnt match the zero index is
.iloc uses the zero index while .ix uses the current, artificial, index
Pandas: To check if any value in a Series passes a value test, type
my_series[my_series > 50].any()
Pandas: To check if all values in a Series passes a value test, type
my_series[my_series > 50].all()
Pandas: To sum how many values in a Series pass a value test, type
sum(my_series > 5)
Pandas: Can you do a step when slicing a Series
Yes
Pandas: df[“Campaign name”] is the data type
Series
Pandas: To create a copy of a df, type
df_copied = df.copy()
Pandas: To add the rows of one df to another that has the same columns, type
df_concated = pandas.concat([df, df2])
Pandas: With regard to nan values, pandas will
ignore them
Pandas: When you concatenate two dfs the index will
be maintained, so if the dfs were both zero indexed, they there will be duplicates index values.
Pandas: To return the length of a df column, type
df[“Column name”].count()
Pandas: Anything action you can perform on a Series can be also performed on a
df[“Column name”]
Pandas: To forward fill the na values in a Series, type
concated_df.ffill()
Pandas: To backwards fill the na values in a Series, type
concated_df.bfill()
Pandas: To replace the index of a concated df with one that is ordered, type
concated_df.index = range(concated_df[“Column name”].count())
Pandas: df[“column 1”] + df[“column 1”], is an
index based arithmetic. If the indexes are not aligned it will add the wrong rows together.
Pandas: When multiplying two Series, if there are many indices with the same value, pandas will
multiply every combination of the values and add new rows for each product.
Pandas: If you decide to create a DataFrame with lists rather than dicts, the column labels will
Just be set to zero index numbers.
Pandas: To name unnamed columns, type
df.columns = [“Column 1”, “Column 2”]
Pandas: To filter for indexes in a pivot_table, type
pvt.query(‘Type == [“Banner”, “Text”]’)
Pandas: To drill down to a certain value in a certain level of a pivot_table, type
pvt.xs(“Value name”, level=0)
SQL: To select everything from a table, type
SELECT * FROM table
SQL: A databases structure is called it’s
schema
SQL: The three main types of data you can set a column to hold are
String, Numeric, Date and Time
SQL: The two types of string data are
Text and Varchar
SQL: Varchar string type is ideal for
Short strings, like names
SQL: Text string type is ideal for
Long strings, like descriptions
SQL: The numeric data types are
Integers, Fixed Point Decimal, Float
SQL: The fixed point data type
Sets a strict number of decimal places and is ideal for dollars
SQL: The float point data type
does not set a strict number of decimal places
SQL: The best data type to store a date and time together is
datetime
SQL: To create a table with one column that stores 50 characters, type
CREATE TABLE tablename (columnname VARCHAR(50));
SQL: To create a table with two columns, one that stores 50 characters, and another that store integers, type
CREATE TABLE tablename (columnname VARCHAR(50), columnname INTEGER);
SQL: To insert data into a row, type
INSERT INTO table VALUES (“String”, 1000);
SQL: When inserting values into the DB, the values must
be in the same order you defined in the table.
SQL: String you insert must have
quotes