Created
November 24, 2021 03:26
-
-
Save vinayakvanarse/a8136cf2f9d198524b995bd3126b0b37 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# pip3 install requests -t . | |
# pip install -r requirements.txt -t . | |
# requirements.txt | |
# numpy | |
# pandas | |
# openpyxl | |
# xlrd | |
# xlwt | |
# XlsxWriter | |
from numpy import newaxis | |
import pandas as pd | |
excel_file = 'book.xlsx' | |
# xlsx = pd.ExcelFile(excel_file) | |
# movies_sheets = [] | |
# for sheet in xlsx.sheet_names: | |
# movies_sheets.append(xlsx.parse(sheet)) | |
# movies = pd.concat(movies_sheets) | |
jira_ref = pd.read_excel(excel_file, sheet_name=0) | |
jira = pd.read_excel(excel_file, sheet_name=1) | |
shape = jira_ref.head() | |
# print(shape) | |
shape = jira.head() | |
# print(shape) | |
print('\n\n') | |
# inner join of ref table | |
fltr_ref = jira_ref.loc[jira_ref['Key'].isin(jira["slater_key"])] | |
# print (fltr_ref) | |
data = [] | |
for indx in range(jira.shape[0]): | |
vl = fltr_ref["Key"] == jira.at[indx, "slater_key"] | |
rw = fltr_ref[vl] | |
jw = jira.iloc[indx] | |
if not rw.empty: | |
jw.at["mission_theme_index"] = rw["Index"].item() | |
jw.at["mission_theme_key"] = rw["Key"].item() | |
idv = rw["Index"].item() | |
sidv = idv.split('.') | |
nwIdx = sidv[0] + "." + sidv[1] | |
# print(nwIdx) | |
new_fltr_ref = jira_ref.loc[jira_ref['Index'].isin([nwIdx])] | |
print(new_fltr_ref) | |
jw.at["mission_theme_key"] = new_fltr_ref["Key"].item() | |
data.append(jw) | |
# print (data) | |
df = pd.DataFrame(data) | |
print(df.head()) | |
df.to_excel("output.xlsx") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
first cfommt