This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gs_group(df): | |
gs_dict = {'GS-1' : 'GS 1-6', | |
'GS-2' : 'GS 1-6', | |
'GS-3' : 'GS 1-6', | |
'GS-4' : 'GS 1-6', | |
'GS-5' : 'GS 1-6', | |
'GS-6' : 'GS 1-6', | |
'GS-7' : 'GS 7-9', | |
'GS-8' : 'GS 7-9', | |
'GS-9' : 'GS 7-9', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, gzip, shutil | |
dir_name = 'x' | |
def gz_extract(directory): | |
extension = ".gz" | |
os.chdir(directory) | |
for item in os.listdir(directory): # loop through items in dir | |
if item.endswith(extension): # check for ".gz" extension | |
gz_name = os.path.abspath(item) # get full path of files |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def quick_melt(wide_df): | |
''' | |
Take wide dataframe and melt to long. Declare ID Columns (id_cols) | |
and then establish all remaining columns as value columns | |
''' | |
id_cols = {'A', 'B', 'C'} | |
value_cols = set(wide_df.columns) - id_cols |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import os | |
import glob | |
def read_multi_csv(path): | |
''' | |
Given a file path with wildcard and extension, parse all files with that extension in directory | |
into a single dataframe. | |
''' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import os | |
import glob | |
def read_multi_excel(path): | |
''' | |
Given a file path with wildcard and extension, parse all files with that extension in directory | |
into a single dataframe. | |
''' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import glob | |
def read_multi_csv(path): | |
''' | |
Given a file path with wildcard and extension, parse all files with that extension in directory | |
into a single dataframe. | |
''' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import glob | |
def read_multi_excel(path): | |
''' | |
Given a file path with wildcard and extension, parse all files with that extension in directory | |
into a single dataframe. | |
''' | |
all_files = glob.glob(path) |