Created
June 7, 2019 16:11
-
-
Save mbstacy/28a52c4c3c68fa094e3c465bbaf04bcf to your computer and use it in GitHub Desktop.
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 | |
#error file generated in bash: $cat dm-ir.log | awk '{print $5,$8}' > errors2.txt | |
err=pd.read_csv('errors2.txt',delim_whitespace=True,header=None ) | |
err.columns=['error_type','context_key'] | |
err=err.drop_duplicates() | |
#Main inventory | |
df=pd.read_csv('data/inventory-2019-05-30.csv',converters={i: str for i in range(0, 83)}) | |
df= df.drop_duplicates() | |
#merge defaults to inner join | |
result=err.merge(df,on='context_key') | |
result.to_csv('mynewerrors.csv') | |
#Pandas | |
# https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.read_csv.html | |
# https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.merge.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment