help:python:python_ref
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | help:python:python_ref [2020/06/20 14:39] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ~~NOTOC~~ | ||
+ | |<100% 25% - >| | ||
+ | ^ \\ DATA ANALYTICS REFERENCE DOCUMENT\\ \\ ^^ | ||
+ | ^ Document Title: | ||
+ | ^ Document No.: | ||
+ | ^ Author(s): | ||
+ | ^ Contributor(s): | ||
+ | |||
+ | |||
+ | **REVISION HISTORY** | ||
+ | |< 100% 10% - - 10% 17% 10% >| | ||
+ | ^ \\ Revision\\ | ||
+ | | [[: | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ====== Python Reference ====== | ||
+ | |||
+ | There' | ||
+ | |||
+ | ===== Pandas ===== | ||
+ | |||
+ | Query a dataframe for a string in a field | ||
+ | <code python df_query.py> | ||
+ | df[df[' | ||
+ | </ | ||
+ | The string in the sample is over complicated and includes a regulate expression, so can be a simple string, but has the ability to include regular expressions too. | ||
+ | |||
+ | <code python> | ||
+ | #read a csv into a dataframe | ||
+ | csv=pd.read_csv(' | ||
+ | df=pd.read_csv(" | ||
+ | h5=pd.read_hdf(' | ||
+ | csv[' | ||
+ | csv[' | ||
+ | csv[' | ||
+ | h5.append(csv) | ||
+ | new=h5.append(csv) | ||
+ | new=new.reset_index(drop=True) | ||
+ | new.to_hdf(' | ||
+ | |||
+ | #merging dataframes on column | ||
+ | b2=pd.merge(bom, | ||
+ | |||
+ | #vlookup for dataframes | ||
+ | df5.loc[df5.Item.isin(dfu.ms), | ||
+ | |||
+ | db=pd.read_hdf(' | ||
+ | # db=pd.read_hdf(' | ||
+ | # | ||
+ | |||
+ | #specify column names | ||
+ | db.columns=[' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | ' | ||
+ | |||
+ | # Filer on tool ID | ||
+ | db=db[db[' | ||
+ | # Filter on Job ID - B4300 - A3225 | ||
+ | db=db[db[' | ||
+ | # remove the runtime outliers | ||
+ | db=db[abs(db[' | ||
+ | # remove the runtime outliers | ||
+ | db=db[abs(db[' | ||
+ | # remove the runtime outliers | ||
+ | db=db[abs(db[' | ||
+ | #remove times before jan2017 | ||
+ | db=db[db[' | ||
+ | #remove times greater than now | ||
+ | db=db[db[' | ||
+ | |||
+ | </ |
help/python/python_ref.txt · Last modified: 2020/06/20 14:39 by 127.0.0.1