f64
commited on
Commit
·
856969c
1
Parent(s):
c953f8d
- my_static_methods.py +57 -6
- pages/6_TECT_7_ID.py +84 -56
- static/test.ipynb +505 -76
my_static_methods.py
CHANGED
|
@@ -1,9 +1,13 @@
|
|
| 1 |
from typing import Union, NamedTuple
|
| 2 |
-
import os,
|
| 3 |
import numpy as np, pandas as pd
|
| 4 |
import plotly.express as px
|
| 5 |
import huggingface_hub
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
os.makedirs(".temp", exist_ok=True) # for temporary local files
|
| 8 |
|
| 9 |
class HfRepo(NamedTuple):
|
|
@@ -105,11 +109,58 @@ def plotly_xyzv_scatter_gray(df3D):
|
|
| 105 |
return fig
|
| 106 |
|
| 107 |
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
|
| 115 |
|
|
|
|
| 1 |
from typing import Union, NamedTuple
|
| 2 |
+
import io,os,re,sys,math,time,uuid,ctypes,pickle,random,shutil,string,urllib,decimal,datetime,itertools,traceback,collections,statistics
|
| 3 |
import numpy as np, pandas as pd
|
| 4 |
import plotly.express as px
|
| 5 |
import huggingface_hub
|
| 6 |
|
| 7 |
+
import sklearn #, statsmodels
|
| 8 |
+
from sklearn import svm, neighbors, naive_bayes, neural_network, tree, ensemble, linear_model, discriminant_analysis, gaussian_process, manifold, cluster
|
| 9 |
+
#from statsmodels.tsa import seasonal
|
| 10 |
+
|
| 11 |
os.makedirs(".temp", exist_ok=True) # for temporary local files
|
| 12 |
|
| 13 |
class HfRepo(NamedTuple):
|
|
|
|
| 109 |
return fig
|
| 110 |
|
| 111 |
|
| 112 |
+
# lstRepoZipFiles = ["TrainData_1504_AB_gaziev.zip","TestData_1504_AB_gaziev.zip","TestData3_2204_noAB_gaziev.zip"]
|
| 113 |
+
### returns (classifier_object, df_train_with_predict, time_elapsed)
|
| 114 |
+
def GetClassifier(lstDfOriginal, nHystorySteps) :
|
| 115 |
+
#lstDfOriginal = [df_9125_Train, df_12010_Test, df_9051_Test3]
|
| 116 |
+
nShift = nHystorySteps
|
| 117 |
+
nCurrShift = nHystorySteps
|
| 118 |
+
classifierName = "DecisionTreeClassifier"
|
| 119 |
+
colsVectorInp = ["X","Y","Z"]
|
| 120 |
+
fieldY = "Vis" #
|
| 121 |
+
lstDataFrames = MakeHystoryColumns(lstDfOriginal, nShift)
|
| 122 |
+
df_train = pd.concat(lstDataFrames)
|
| 123 |
+
lstColsShift = [f"{c}-{i}" for i in range(1, nCurrShift+1) for c in colsVectorInp] # для nCurrShift=0 lstColsShift=[]
|
| 124 |
+
colsVectorInpAll = colsVectorInp + lstColsShift
|
| 125 |
+
y_train = df_train[fieldY]
|
| 126 |
+
x_train_vect = df_train[colsVectorInpAll]
|
| 127 |
+
dictClassifiers = createDictClassifiers_BestForXYZ()
|
| 128 |
+
classifierObject = dictClassifiers[classifierName]
|
| 129 |
+
start2 = time.time()
|
| 130 |
+
classifierObject.fit(x_train_vect, y_train) # процесс обучения
|
| 131 |
+
time_elapsed = time.time() - start2
|
| 132 |
+
y_pred = classifierObject.predict(x_train_vect)
|
| 133 |
+
df_train[f"predict_{fieldY}"] = y_pred
|
| 134 |
+
print(f"{time_elapsed=}")
|
| 135 |
+
return (classifierObject, df_train, time_elapsed)
|
| 136 |
+
|
| 137 |
+
#
|
| 138 |
+
def MakeHystoryColumns(lstDfOriginal, nShift) :
|
| 139 |
+
lstDataframesShifted = [df.copy() for df in lstDfOriginal]
|
| 140 |
+
lstColsShift = []
|
| 141 |
+
for i in range(1, nShift+1):
|
| 142 |
+
#cols = ["X","Y","Z"]+["A","B"]
|
| 143 |
+
cols = ["X","Y","Z"]
|
| 144 |
+
#cols = ["A","B"]
|
| 145 |
+
for c in cols:
|
| 146 |
+
for dfShift in lstDataframesShifted:
|
| 147 |
+
dfShift[f'{c}-{i}'] = dfShift[c].shift(i).fillna(0)
|
| 148 |
+
lstColsShift.append(lstDataframesShifted[0].columns[-1])
|
| 149 |
+
print(lstColsShift)
|
| 150 |
+
return lstDataframesShifted
|
| 151 |
+
|
| 152 |
+
RANDOM_STATE=11
|
| 153 |
+
|
| 154 |
+
def createDictClassifiers_BestForXYZ() :
|
| 155 |
+
dictFastTree = {
|
| 156 |
+
#"RandomForestClassifier": ensemble.RandomForestClassifier(random_state=RANDOM_STATE), # совсем плохие показатели
|
| 157 |
+
#"ExtraTreeClassifier": tree.ExtraTreeClassifier(random_state=RANDOM_STATE), #
|
| 158 |
+
"DecisionTreeClassifier": tree.DecisionTreeClassifier(random_state=RANDOM_STATE), # лучший по последним баллам
|
| 159 |
+
}
|
| 160 |
+
#return {**dictFast}
|
| 161 |
+
#return {**dict_Test_MLPClassifier}
|
| 162 |
+
#return {**dictFast, **dictLongTrain}
|
| 163 |
+
return {**dictFastTree}
|
| 164 |
|
| 165 |
|
| 166 |
|
pages/6_TECT_7_ID.py
CHANGED
|
@@ -3,18 +3,28 @@ import streamlit as st, pandas as pd, numpy as np
|
|
| 3 |
import my_static_methods as my_stm
|
| 4 |
|
| 5 |
st.html(my_stm.STYLE_CORRECTION)
|
| 6 |
-
#st.sidebar.markdown("🧊 проверка по пакетам XYZ")
|
| 7 |
-
st.info("🧊 проверка предсказаний по пакетам XYZ")
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
try: st.rerun()
|
| 11 |
except: pass
|
| 12 |
|
| 13 |
def DescriptionMarkdown() -> str:
|
| 14 |
return """
|
| 15 |
## Описание
|
| 16 |
-
|
| 17 |
Источником данных является файл CSV
|
|
|
|
| 18 |
"""
|
| 19 |
|
| 20 |
def save_dataframe_nodialog_idxyz(new_filename, dfToSave):
|
|
@@ -22,66 +32,84 @@ def save_dataframe_nodialog_idxyz(new_filename, dfToSave):
|
|
| 22 |
st.toast(commit_info, icon='🆕')
|
| 23 |
ReRun()
|
| 24 |
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
col1
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
if uploaded_file
|
| 37 |
-
dfLoaded =
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
if uploaded_file.type == "
|
| 41 |
-
try: dfLoaded = pd.read_csv(uploaded_file, sep=delim, encoding=enc)
|
| 42 |
except Exception as ex: st.write(ex)
|
| 43 |
else:
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
if len(lst_len) == 1:
|
| 63 |
-
fileXYZ = f"{colnames}_{len(dictGroupID)}x{lst_len[0]}_{lstGroupIDs[0]}_{lstGroupIDs[-1]}.csv".upper()
|
| 64 |
-
if fileXYZ in dictTestFilesIdXyz.keys():
|
| 65 |
-
if st.button(f"такой файл есть! перезаписать файл '{fileXYZ}'?"):
|
| 66 |
-
save_dataframe_nodialog_idxyz(fileXYZ, dfToUpload)
|
| 67 |
-
else:
|
| 68 |
save_dataframe_nodialog_idxyz(fileXYZ, dfToUpload)
|
| 69 |
else:
|
| 70 |
-
|
| 71 |
else:
|
| 72 |
-
st.error(f"
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
dgID = df_idxyz.groupby("ID")
|
| 81 |
-
dictGroupID = dict(list(dgID))
|
| 82 |
-
dfShow = dgID.apply(len) #.reset_index()
|
| 83 |
-
col2.dataframe(dfShow, height=700)
|
| 84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
|
| 87 |
|
|
|
|
| 3 |
import my_static_methods as my_stm
|
| 4 |
|
| 5 |
st.html(my_stm.STYLE_CORRECTION)
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
REPO = my_stm.HfRepo("f64k/gaziev", "dataset", st.secrets["HF_WRITE"])
|
| 8 |
+
lstRepoFiles = my_stm.list_files_hf(REPO) # список уже имеющихся в репозитории файлов
|
| 9 |
+
dictTestFilesIdXyz = {f.upper().replace("ID_XYZ/",""): f.upper() for f in lstRepoFiles if f.upper().startswith("ID_XYZ/")}
|
| 10 |
+
|
| 11 |
+
@st.cache_data
|
| 12 |
+
def GetListOf_XYZV_ToTrainClassifier(repo):
|
| 13 |
+
lstRepoZipFiles = ["TrainData_1504_AB_gaziev.zip","TestData_1504_AB_gaziev.zip","TestData3_2204_noAB_gaziev.zip"]
|
| 14 |
+
dictTrainThreeDataframes = my_stm.load_dataframes_from_hf(REPO, lstRepoZipFiles)
|
| 15 |
+
lstDfOriginal = [my_stm.df_process_v_column(df) for df in dictTrainThreeDataframes.values()]
|
| 16 |
+
return lstDfOriginal
|
| 17 |
+
|
| 18 |
+
def ReRun() :
|
| 19 |
try: st.rerun()
|
| 20 |
except: pass
|
| 21 |
|
| 22 |
def DescriptionMarkdown() -> str:
|
| 23 |
return """
|
| 24 |
## Описание
|
| 25 |
+
### 1) Загрузка нового файла
|
| 26 |
Источником данных является файл CSV
|
| 27 |
+
Первая строка - названия столбцов ID;X;Y;Z
|
| 28 |
"""
|
| 29 |
|
| 30 |
def save_dataframe_nodialog_idxyz(new_filename, dfToSave):
|
|
|
|
| 32 |
st.toast(commit_info, icon='🆕')
|
| 33 |
ReRun()
|
| 34 |
|
| 35 |
+
#st.sidebar.markdown("🧊 проверка по пакетам XYZ")
|
| 36 |
|
| 37 |
+
with st.container():
|
| 38 |
+
cols1 = st.columns([1,16]) # vertical_alignment: "center"
|
| 39 |
+
cols1[0].popover("❓", help="пояснения").markdown(DescriptionMarkdown())
|
| 40 |
+
cols1[1].info("🔮 проверка предсказаний по пакетам ID_XYZ. 📜 формат CSV. 🧊 названия столбцов ID;X;Y;Z. 📐 размер пакетов одинаковый.")
|
| 41 |
+
|
| 42 |
+
#col1, col2 = st.columns([2,5])
|
| 43 |
+
col1, col2 = st.columns([3,2])
|
| 44 |
|
| 45 |
+
with col1.popover("🆕 добавить новый файл", use_container_width=False):
|
| 46 |
+
uploaded_file = st.file_uploader("💾 “откройте CSV для загрузки”", ["csv"])
|
| 47 |
+
if uploaded_file is not None:
|
| 48 |
+
dfLoaded = None
|
| 49 |
+
delim = ";"
|
| 50 |
+
enc = "utf-8"
|
| 51 |
+
if uploaded_file.type == "text/csv":
|
| 52 |
+
try: dfLoaded = pd.read_csv(uploaded_file, sep=delim, encoding=enc)
|
| 53 |
+
except Exception as ex: st.write(ex)
|
| 54 |
+
else:
|
| 55 |
+
if uploaded_file.type == "application/x-zip-compressed":
|
| 56 |
+
try: dfLoaded = pd.read_csv(uploaded_file, sep=delim, encoding=enc, compression="zip")
|
| 57 |
except Exception as ex: st.write(ex)
|
| 58 |
else:
|
| 59 |
+
st.error(uploaded_file.type)
|
| 60 |
+
# dataframe ready. try to upload to HF
|
| 61 |
+
if not dfLoaded is None:
|
| 62 |
+
dfToUpload = dfLoaded
|
| 63 |
+
if "ID" in dfToUpload.columns:
|
| 64 |
+
dfToUpload = dfLoaded.query("ID!='ID'")
|
| 65 |
+
#col2.dataframe(df)
|
| 66 |
+
colnames = "".join(dfToUpload.columns)
|
| 67 |
+
if colnames.upper().startswith("IDXYZ"):
|
| 68 |
+
dgID = dfToUpload.groupby("ID")
|
| 69 |
+
dictGroupID = dict(list(dgID))
|
| 70 |
+
lstGroupIDs = list(dictGroupID.keys())
|
| 71 |
+
#col2.write(dictGroupID)
|
| 72 |
+
lst_len = list(set(dgID.apply(len)))
|
| 73 |
+
if len(lst_len) == 1:
|
| 74 |
+
fileXYZ = f"{colnames}_{len(dictGroupID)}x{lst_len[0]}_{lstGroupIDs[0]}_{lstGroupIDs[-1]}.csv".upper()
|
| 75 |
+
if fileXYZ in dictTestFilesIdXyz.keys():
|
| 76 |
+
if st.button(f"такой файл есть! перезаписать файл '{fileXYZ}'?"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
save_dataframe_nodialog_idxyz(fileXYZ, dfToUpload)
|
| 78 |
else:
|
| 79 |
+
save_dataframe_nodialog_idxyz(fileXYZ, dfToUpload)
|
| 80 |
else:
|
| 81 |
+
st.error(f"Разные размеры пакетов для разных ID, варианты : {lst_len}")
|
| 82 |
+
else:
|
| 83 |
+
st.error(f"Столбцы не ID;X;Y;Z ! Наблюдаем столбцы : {colnames}")
|
| 84 |
+
|
| 85 |
+
# список уже имеющихся в репозитории файлов
|
| 86 |
+
lstRepoFiles = my_stm.list_files_hf(REPO)
|
| 87 |
+
dictTestFilesIdXyz = {f.upper().replace("ID_XYZ/",""): f.upper() for f in lstRepoFiles if f.upper().startswith("ID_XYZ/")}
|
| 88 |
+
selectedFile = col1.radio("📰 загруженные тестовые пакеты", dictTestFilesIdXyz.keys(), index=None)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
|
| 90 |
+
# выбран файл для предсказания
|
| 91 |
+
if selectedFile is not None:
|
| 92 |
+
dict_ONE_IDXYZ = my_stm.load_dataframes_from_hf(REPO, [dictTestFilesIdXyz[selectedFile]])
|
| 93 |
+
if len(dict_ONE_IDXYZ) > 0:
|
| 94 |
+
df_idxyz = list(dict_ONE_IDXYZ.values())[0]
|
| 95 |
+
dfShow = df_idxyz
|
| 96 |
+
dgID = df_idxyz.groupby("ID")
|
| 97 |
+
dictGroupID = dict(list(dgID))
|
| 98 |
+
dfShow = dgID.apply(len).reset_index()
|
| 99 |
+
#col1.dataframe(dfShow, height=400)
|
| 100 |
+
pack_size = list(set(dgID.apply(len)))[0]
|
| 101 |
+
lstDfOriginal = GetListOf_XYZV_ToTrainClassifier(REPO)
|
| 102 |
+
classifier_object, df_train_with_predict, time_elapsed = my_stm.GetClassifier(lstDfOriginal, pack_size-1)
|
| 103 |
+
col2.popover(type(classifier_object).__name__).write(type(classifier_object))
|
| 104 |
+
# прогноз на обучающей выборке
|
| 105 |
+
columns_xyzv = [c for c in df_train_with_predict.columns if "Vis" in c] + [c for c in df_train_with_predict.columns if c[0] in "XYZ"]
|
| 106 |
+
#col2.dataframe(df_train_with_predict[columns_xyzv], height=650)
|
| 107 |
+
# расчет пакетов
|
| 108 |
+
xyz = ["X","Y","Z"]
|
| 109 |
+
df_packs_reshaped = dgID.apply(lambda df: pd.Series(df[xyz].values[::-1].reshape(1,-1)[0])).reset_index()
|
| 110 |
+
x_test_vect = df_packs_reshaped.iloc[:,1:]
|
| 111 |
+
df_packs_reshaped["Прогноз_V"] = classifier_object.predict(x_test_vect)
|
| 112 |
+
col2.dataframe(df_packs_reshaped[["ID","Прогноз_V"]], height=650)
|
| 113 |
|
| 114 |
|
| 115 |
|
static/test.ipynb
CHANGED
|
@@ -25,7 +25,7 @@
|
|
| 25 |
"text": [
|
| 26 |
"<>:1: SyntaxWarning: invalid escape sequence '\\M'\n",
|
| 27 |
"<>:1: SyntaxWarning: invalid escape sequence '\\M'\n",
|
| 28 |
-
"C:\\Users\\f64\\AppData\\Local\\Temp\\
|
| 29 |
" path1 = \"N:\\Makarov\\Development\\Python\\Jupiter Notebooks\\Gaziev CSV\\TestData_1504_AB_soloV_gaziev.zip\"\n"
|
| 30 |
]
|
| 31 |
},
|
|
@@ -456,7 +456,7 @@
|
|
| 456 |
},
|
| 457 |
{
|
| 458 |
"cell_type": "code",
|
| 459 |
-
"execution_count":
|
| 460 |
"metadata": {},
|
| 461 |
"outputs": [
|
| 462 |
{
|
|
@@ -470,9 +470,9 @@
|
|
| 470 |
"name": "stderr",
|
| 471 |
"output_type": "stream",
|
| 472 |
"text": [
|
| 473 |
-
"C:\\Users\\f64\\AppData\\Local\\Temp\\
|
| 474 |
" print(f\"{set(df2.groupby(\"ID\").apply(len))=}\")\n",
|
| 475 |
-
"C:\\Users\\f64\\AppData\\Local\\Temp\\
|
| 476 |
" dgID.apply(len).reset_index()\n"
|
| 477 |
]
|
| 478 |
},
|
|
@@ -630,7 +630,7 @@
|
|
| 630 |
"19 DDD011113 7"
|
| 631 |
]
|
| 632 |
},
|
| 633 |
-
"execution_count":
|
| 634 |
"metadata": {},
|
| 635 |
"output_type": "execute_result"
|
| 636 |
}
|
|
@@ -644,13 +644,15 @@
|
|
| 644 |
},
|
| 645 |
{
|
| 646 |
"cell_type": "code",
|
| 647 |
-
"execution_count":
|
| 648 |
"metadata": {},
|
| 649 |
"outputs": [
|
| 650 |
{
|
| 651 |
"name": "stdout",
|
| 652 |
"output_type": "stream",
|
| 653 |
"text": [
|
|
|
|
|
|
|
| 654 |
"[['-200' '573' '-505' '-21' '602' '-558' '-122' '636' '-592' '-211' '579'\n",
|
| 655 |
" '-752' '-221' '577' '-859' '102' '578' '-830' '-210' '529' '-943']]\n"
|
| 656 |
]
|
|
@@ -747,7 +749,7 @@
|
|
| 747 |
"79 BBB011112 -210 529 -943"
|
| 748 |
]
|
| 749 |
},
|
| 750 |
-
"execution_count":
|
| 751 |
"metadata": {},
|
| 752 |
"output_type": "execute_result"
|
| 753 |
}
|
|
@@ -757,22 +759,24 @@
|
|
| 757 |
"#dgID.apply(lambda df: type(df))\n",
|
| 758 |
"#df2.groupby(\"ID\").apply(lambda df: list(df.columns))\n",
|
| 759 |
"dgID.get_group(\"BBB011112\")\n",
|
| 760 |
-
"print(dictGroupID[\"BBB011112\"][xyz].values.reshape(1
|
|
|
|
|
|
|
| 761 |
"dictGroupID[\"BBB011112\"]\n",
|
| 762 |
"#dgID.indices\n"
|
| 763 |
]
|
| 764 |
},
|
| 765 |
{
|
| 766 |
"cell_type": "code",
|
| 767 |
-
"execution_count":
|
| 768 |
"metadata": {},
|
| 769 |
"outputs": [
|
| 770 |
{
|
| 771 |
"name": "stderr",
|
| 772 |
"output_type": "stream",
|
| 773 |
"text": [
|
| 774 |
-
"C:\\Users\\f64\\AppData\\Local\\Temp\\
|
| 775 |
-
" dgID.apply(lambda df: df[xyz].values.reshape(1
|
| 776 |
]
|
| 777 |
},
|
| 778 |
{
|
|
@@ -796,151 +800,576 @@
|
|
| 796 |
" <thead>\n",
|
| 797 |
" <tr style=\"text-align: right;\">\n",
|
| 798 |
" <th></th>\n",
|
| 799 |
-
" <th>ID</th>\n",
|
| 800 |
" <th>0</th>\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 801 |
" </tr>\n",
|
| 802 |
" </thead>\n",
|
| 803 |
" <tbody>\n",
|
| 804 |
" <tr>\n",
|
| 805 |
" <th>0</th>\n",
|
| 806 |
-
" <td
|
| 807 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 808 |
" </tr>\n",
|
| 809 |
" <tr>\n",
|
| 810 |
" <th>1</th>\n",
|
| 811 |
-
" <td>
|
| 812 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 813 |
" </tr>\n",
|
| 814 |
" <tr>\n",
|
| 815 |
" <th>2</th>\n",
|
| 816 |
-
" <td
|
| 817 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 818 |
" </tr>\n",
|
| 819 |
" <tr>\n",
|
| 820 |
" <th>3</th>\n",
|
| 821 |
-
" <td>
|
| 822 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 823 |
" </tr>\n",
|
| 824 |
" <tr>\n",
|
| 825 |
" <th>4</th>\n",
|
| 826 |
-
" <td
|
| 827 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 828 |
" </tr>\n",
|
| 829 |
" <tr>\n",
|
| 830 |
" <th>5</th>\n",
|
| 831 |
-
" <td>
|
| 832 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 833 |
" </tr>\n",
|
| 834 |
" <tr>\n",
|
| 835 |
" <th>6</th>\n",
|
| 836 |
-
" <td
|
| 837 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 838 |
" </tr>\n",
|
| 839 |
" <tr>\n",
|
| 840 |
" <th>7</th>\n",
|
| 841 |
-
" <td
|
| 842 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 843 |
" </tr>\n",
|
| 844 |
" <tr>\n",
|
| 845 |
" <th>8</th>\n",
|
| 846 |
-
" <td
|
| 847 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 848 |
" </tr>\n",
|
| 849 |
" <tr>\n",
|
| 850 |
" <th>9</th>\n",
|
| 851 |
-
" <td
|
| 852 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 853 |
" </tr>\n",
|
| 854 |
" <tr>\n",
|
| 855 |
" <th>10</th>\n",
|
| 856 |
-
" <td
|
| 857 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 858 |
" </tr>\n",
|
| 859 |
" <tr>\n",
|
| 860 |
" <th>11</th>\n",
|
| 861 |
-
" <td
|
| 862 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 863 |
" </tr>\n",
|
| 864 |
" <tr>\n",
|
| 865 |
" <th>12</th>\n",
|
| 866 |
-
" <td>
|
| 867 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 868 |
" </tr>\n",
|
| 869 |
" <tr>\n",
|
| 870 |
" <th>13</th>\n",
|
| 871 |
-
" <td
|
| 872 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 873 |
" </tr>\n",
|
| 874 |
" <tr>\n",
|
| 875 |
" <th>14</th>\n",
|
| 876 |
-
" <td
|
| 877 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 878 |
" </tr>\n",
|
| 879 |
" <tr>\n",
|
| 880 |
" <th>15</th>\n",
|
| 881 |
-
" <td
|
| 882 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 883 |
" </tr>\n",
|
| 884 |
" <tr>\n",
|
| 885 |
" <th>16</th>\n",
|
| 886 |
-
" <td
|
| 887 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 888 |
" </tr>\n",
|
| 889 |
" <tr>\n",
|
| 890 |
" <th>17</th>\n",
|
| 891 |
-
" <td
|
| 892 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 893 |
" </tr>\n",
|
| 894 |
" <tr>\n",
|
| 895 |
" <th>18</th>\n",
|
| 896 |
-
" <td>
|
| 897 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 898 |
" </tr>\n",
|
| 899 |
" <tr>\n",
|
| 900 |
" <th>19</th>\n",
|
| 901 |
-
" <td>
|
| 902 |
-
" <td>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 903 |
" </tr>\n",
|
| 904 |
" </tbody>\n",
|
| 905 |
"</table>\n",
|
|
|
|
| 906 |
"</div>"
|
| 907 |
],
|
| 908 |
"text/plain": [
|
| 909 |
-
"
|
| 910 |
-
"0
|
| 911 |
-
"1
|
| 912 |
-
"2
|
| 913 |
-
"3
|
| 914 |
-
"4
|
| 915 |
-
"5
|
| 916 |
-
"6
|
| 917 |
-
"7
|
| 918 |
-
"8
|
| 919 |
-
"9
|
| 920 |
-
"10
|
| 921 |
-
"11
|
| 922 |
-
"12
|
| 923 |
-
"13
|
| 924 |
-
"14
|
| 925 |
-
"15
|
| 926 |
-
"16
|
| 927 |
-
"17
|
| 928 |
-
"18
|
| 929 |
-
"19
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 930 |
]
|
| 931 |
},
|
| 932 |
-
"execution_count":
|
| 933 |
"metadata": {},
|
| 934 |
"output_type": "execute_result"
|
| 935 |
}
|
| 936 |
],
|
| 937 |
"source": [
|
| 938 |
-
"dgID.apply(lambda df: df[xyz].values.reshape(1,21)).reset_index()"
|
|
|
|
| 939 |
]
|
| 940 |
},
|
| 941 |
{
|
| 942 |
"cell_type": "code",
|
| 943 |
-
"execution_count":
|
| 944 |
"metadata": {},
|
| 945 |
"outputs": [
|
| 946 |
{
|
|
|
|
| 25 |
"text": [
|
| 26 |
"<>:1: SyntaxWarning: invalid escape sequence '\\M'\n",
|
| 27 |
"<>:1: SyntaxWarning: invalid escape sequence '\\M'\n",
|
| 28 |
+
"C:\\Users\\f64\\AppData\\Local\\Temp\\ipykernel_36416\\1255343956.py:1: SyntaxWarning: invalid escape sequence '\\M'\n",
|
| 29 |
" path1 = \"N:\\Makarov\\Development\\Python\\Jupiter Notebooks\\Gaziev CSV\\TestData_1504_AB_soloV_gaziev.zip\"\n"
|
| 30 |
]
|
| 31 |
},
|
|
|
|
| 456 |
},
|
| 457 |
{
|
| 458 |
"cell_type": "code",
|
| 459 |
+
"execution_count": 5,
|
| 460 |
"metadata": {},
|
| 461 |
"outputs": [
|
| 462 |
{
|
|
|
|
| 470 |
"name": "stderr",
|
| 471 |
"output_type": "stream",
|
| 472 |
"text": [
|
| 473 |
+
"C:\\Users\\f64\\AppData\\Local\\Temp\\ipykernel_36416\\117446433.py:1: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n",
|
| 474 |
" print(f\"{set(df2.groupby(\"ID\").apply(len))=}\")\n",
|
| 475 |
+
"C:\\Users\\f64\\AppData\\Local\\Temp\\ipykernel_36416\\117446433.py:4: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n",
|
| 476 |
" dgID.apply(len).reset_index()\n"
|
| 477 |
]
|
| 478 |
},
|
|
|
|
| 630 |
"19 DDD011113 7"
|
| 631 |
]
|
| 632 |
},
|
| 633 |
+
"execution_count": 5,
|
| 634 |
"metadata": {},
|
| 635 |
"output_type": "execute_result"
|
| 636 |
}
|
|
|
|
| 644 |
},
|
| 645 |
{
|
| 646 |
"cell_type": "code",
|
| 647 |
+
"execution_count": 26,
|
| 648 |
"metadata": {},
|
| 649 |
"outputs": [
|
| 650 |
{
|
| 651 |
"name": "stdout",
|
| 652 |
"output_type": "stream",
|
| 653 |
"text": [
|
| 654 |
+
"[['-210' '529' '-943' '102' '578' '-830' '-221' '577' '-859' '-211' '579'\n",
|
| 655 |
+
" '-752' '-122' '636' '-592' '-21' '602' '-558' '-200' '573' '-505']]\n",
|
| 656 |
"[['-200' '573' '-505' '-21' '602' '-558' '-122' '636' '-592' '-211' '579'\n",
|
| 657 |
" '-752' '-221' '577' '-859' '102' '578' '-830' '-210' '529' '-943']]\n"
|
| 658 |
]
|
|
|
|
| 749 |
"79 BBB011112 -210 529 -943"
|
| 750 |
]
|
| 751 |
},
|
| 752 |
+
"execution_count": 26,
|
| 753 |
"metadata": {},
|
| 754 |
"output_type": "execute_result"
|
| 755 |
}
|
|
|
|
| 759 |
"#dgID.apply(lambda df: type(df))\n",
|
| 760 |
"#df2.groupby(\"ID\").apply(lambda df: list(df.columns))\n",
|
| 761 |
"dgID.get_group(\"BBB011112\")\n",
|
| 762 |
+
"print(dictGroupID[\"BBB011112\"][xyz].values.reshape(1,-1))\n",
|
| 763 |
+
"print(dictGroupID[\"BBB011112\"][xyz].values[::-1].reshape(1,-1))\n",
|
| 764 |
+
"\n",
|
| 765 |
"dictGroupID[\"BBB011112\"]\n",
|
| 766 |
"#dgID.indices\n"
|
| 767 |
]
|
| 768 |
},
|
| 769 |
{
|
| 770 |
"cell_type": "code",
|
| 771 |
+
"execution_count": 31,
|
| 772 |
"metadata": {},
|
| 773 |
"outputs": [
|
| 774 |
{
|
| 775 |
"name": "stderr",
|
| 776 |
"output_type": "stream",
|
| 777 |
"text": [
|
| 778 |
+
"C:\\Users\\f64\\AppData\\Local\\Temp\\ipykernel_36416\\1960408511.py:2: DeprecationWarning: DataFrameGroupBy.apply operated on the grouping columns. This behavior is deprecated, and in a future version of pandas the grouping columns will be excluded from the operation. Either pass `include_groups=False` to exclude the groupings or explicitly select the grouping columns after groupby to silence this warning.\n",
|
| 779 |
+
" dgID.apply(lambda df: pd.Series(df[xyz].values[::-1].reshape(1,-1)[0])).reset_index().iloc[:,1:]\n"
|
| 780 |
]
|
| 781 |
},
|
| 782 |
{
|
|
|
|
| 800 |
" <thead>\n",
|
| 801 |
" <tr style=\"text-align: right;\">\n",
|
| 802 |
" <th></th>\n",
|
|
|
|
| 803 |
" <th>0</th>\n",
|
| 804 |
+
" <th>1</th>\n",
|
| 805 |
+
" <th>2</th>\n",
|
| 806 |
+
" <th>3</th>\n",
|
| 807 |
+
" <th>4</th>\n",
|
| 808 |
+
" <th>5</th>\n",
|
| 809 |
+
" <th>6</th>\n",
|
| 810 |
+
" <th>7</th>\n",
|
| 811 |
+
" <th>8</th>\n",
|
| 812 |
+
" <th>9</th>\n",
|
| 813 |
+
" <th>...</th>\n",
|
| 814 |
+
" <th>11</th>\n",
|
| 815 |
+
" <th>12</th>\n",
|
| 816 |
+
" <th>13</th>\n",
|
| 817 |
+
" <th>14</th>\n",
|
| 818 |
+
" <th>15</th>\n",
|
| 819 |
+
" <th>16</th>\n",
|
| 820 |
+
" <th>17</th>\n",
|
| 821 |
+
" <th>18</th>\n",
|
| 822 |
+
" <th>19</th>\n",
|
| 823 |
+
" <th>20</th>\n",
|
| 824 |
" </tr>\n",
|
| 825 |
" </thead>\n",
|
| 826 |
" <tbody>\n",
|
| 827 |
" <tr>\n",
|
| 828 |
" <th>0</th>\n",
|
| 829 |
+
" <td>-200</td>\n",
|
| 830 |
+
" <td>732</td>\n",
|
| 831 |
+
" <td>257</td>\n",
|
| 832 |
+
" <td>211</td>\n",
|
| 833 |
+
" <td>746</td>\n",
|
| 834 |
+
" <td>312</td>\n",
|
| 835 |
+
" <td>-22</td>\n",
|
| 836 |
+
" <td>714</td>\n",
|
| 837 |
+
" <td>277</td>\n",
|
| 838 |
+
" <td>-202</td>\n",
|
| 839 |
+
" <td>...</td>\n",
|
| 840 |
+
" <td>382</td>\n",
|
| 841 |
+
" <td>-221</td>\n",
|
| 842 |
+
" <td>703</td>\n",
|
| 843 |
+
" <td>505</td>\n",
|
| 844 |
+
" <td>200</td>\n",
|
| 845 |
+
" <td>711</td>\n",
|
| 846 |
+
" <td>556</td>\n",
|
| 847 |
+
" <td>111</td>\n",
|
| 848 |
+
" <td>702</td>\n",
|
| 849 |
+
" <td>536</td>\n",
|
| 850 |
" </tr>\n",
|
| 851 |
" <tr>\n",
|
| 852 |
" <th>1</th>\n",
|
| 853 |
+
" <td>202</td>\n",
|
| 854 |
+
" <td>486</td>\n",
|
| 855 |
+
" <td>-547</td>\n",
|
| 856 |
+
" <td>-320</td>\n",
|
| 857 |
+
" <td>452</td>\n",
|
| 858 |
+
" <td>-505</td>\n",
|
| 859 |
+
" <td>-222</td>\n",
|
| 860 |
+
" <td>525</td>\n",
|
| 861 |
+
" <td>-178</td>\n",
|
| 862 |
+
" <td>-102</td>\n",
|
| 863 |
+
" <td>...</td>\n",
|
| 864 |
+
" <td>22</td>\n",
|
| 865 |
+
" <td>-2</td>\n",
|
| 866 |
+
" <td>557</td>\n",
|
| 867 |
+
" <td>58</td>\n",
|
| 868 |
+
" <td>200</td>\n",
|
| 869 |
+
" <td>572</td>\n",
|
| 870 |
+
" <td>50</td>\n",
|
| 871 |
+
" <td>201</td>\n",
|
| 872 |
+
" <td>584</td>\n",
|
| 873 |
+
" <td>-36</td>\n",
|
| 874 |
" </tr>\n",
|
| 875 |
" <tr>\n",
|
| 876 |
" <th>2</th>\n",
|
| 877 |
+
" <td>-302</td>\n",
|
| 878 |
+
" <td>336</td>\n",
|
| 879 |
+
" <td>-443</td>\n",
|
| 880 |
+
" <td>-202</td>\n",
|
| 881 |
+
" <td>343</td>\n",
|
| 882 |
+
" <td>-257</td>\n",
|
| 883 |
+
" <td>-201</td>\n",
|
| 884 |
+
" <td>336</td>\n",
|
| 885 |
+
" <td>-206</td>\n",
|
| 886 |
+
" <td>121</td>\n",
|
| 887 |
+
" <td>...</td>\n",
|
| 888 |
+
" <td>-175</td>\n",
|
| 889 |
+
" <td>-201</td>\n",
|
| 890 |
+
" <td>357</td>\n",
|
| 891 |
+
" <td>-235</td>\n",
|
| 892 |
+
" <td>21</td>\n",
|
| 893 |
+
" <td>392</td>\n",
|
| 894 |
+
" <td>-205</td>\n",
|
| 895 |
+
" <td>-222</td>\n",
|
| 896 |
+
" <td>412</td>\n",
|
| 897 |
+
" <td>-343</td>\n",
|
| 898 |
" </tr>\n",
|
| 899 |
" <tr>\n",
|
| 900 |
" <th>3</th>\n",
|
| 901 |
+
" <td>401</td>\n",
|
| 902 |
+
" <td>681</td>\n",
|
| 903 |
+
" <td>768</td>\n",
|
| 904 |
+
" <td>-212</td>\n",
|
| 905 |
+
" <td>705</td>\n",
|
| 906 |
+
" <td>660</td>\n",
|
| 907 |
+
" <td>220</td>\n",
|
| 908 |
+
" <td>712</td>\n",
|
| 909 |
+
" <td>694</td>\n",
|
| 910 |
+
" <td>401</td>\n",
|
| 911 |
+
" <td>...</td>\n",
|
| 912 |
+
" <td>544</td>\n",
|
| 913 |
+
" <td>-202</td>\n",
|
| 914 |
+
" <td>644</td>\n",
|
| 915 |
+
" <td>372</td>\n",
|
| 916 |
+
" <td>202</td>\n",
|
| 917 |
+
" <td>625</td>\n",
|
| 918 |
+
" <td>446</td>\n",
|
| 919 |
+
" <td>222</td>\n",
|
| 920 |
+
" <td>643</td>\n",
|
| 921 |
+
" <td>403</td>\n",
|
| 922 |
" </tr>\n",
|
| 923 |
" <tr>\n",
|
| 924 |
" <th>4</th>\n",
|
| 925 |
+
" <td>-222</td>\n",
|
| 926 |
+
" <td>525</td>\n",
|
| 927 |
+
" <td>-178</td>\n",
|
| 928 |
+
" <td>-102</td>\n",
|
| 929 |
+
" <td>616</td>\n",
|
| 930 |
+
" <td>22</td>\n",
|
| 931 |
+
" <td>-2</td>\n",
|
| 932 |
+
" <td>557</td>\n",
|
| 933 |
+
" <td>58</td>\n",
|
| 934 |
+
" <td>200</td>\n",
|
| 935 |
+
" <td>...</td>\n",
|
| 936 |
+
" <td>50</td>\n",
|
| 937 |
+
" <td>201</td>\n",
|
| 938 |
+
" <td>584</td>\n",
|
| 939 |
+
" <td>-36</td>\n",
|
| 940 |
+
" <td>-202</td>\n",
|
| 941 |
+
" <td>585</td>\n",
|
| 942 |
+
" <td>-4</td>\n",
|
| 943 |
+
" <td>0</td>\n",
|
| 944 |
+
" <td>645</td>\n",
|
| 945 |
+
" <td>109</td>\n",
|
| 946 |
" </tr>\n",
|
| 947 |
" <tr>\n",
|
| 948 |
" <th>5</th>\n",
|
| 949 |
+
" <td>21</td>\n",
|
| 950 |
+
" <td>405</td>\n",
|
| 951 |
+
" <td>-173</td>\n",
|
| 952 |
+
" <td>-111</td>\n",
|
| 953 |
+
" <td>427</td>\n",
|
| 954 |
+
" <td>-180</td>\n",
|
| 955 |
+
" <td>-200</td>\n",
|
| 956 |
+
" <td>377</td>\n",
|
| 957 |
+
" <td>-150</td>\n",
|
| 958 |
+
" <td>-110</td>\n",
|
| 959 |
+
" <td>...</td>\n",
|
| 960 |
+
" <td>-91</td>\n",
|
| 961 |
+
" <td>-12</td>\n",
|
| 962 |
+
" <td>316</td>\n",
|
| 963 |
+
" <td>-98</td>\n",
|
| 964 |
+
" <td>-200</td>\n",
|
| 965 |
+
" <td>356</td>\n",
|
| 966 |
+
" <td>-136</td>\n",
|
| 967 |
+
" <td>211</td>\n",
|
| 968 |
+
" <td>335</td>\n",
|
| 969 |
+
" <td>-157</td>\n",
|
| 970 |
" </tr>\n",
|
| 971 |
" <tr>\n",
|
| 972 |
" <th>6</th>\n",
|
| 973 |
+
" <td>-102</td>\n",
|
| 974 |
+
" <td>616</td>\n",
|
| 975 |
+
" <td>22</td>\n",
|
| 976 |
+
" <td>-2</td>\n",
|
| 977 |
+
" <td>557</td>\n",
|
| 978 |
+
" <td>58</td>\n",
|
| 979 |
+
" <td>200</td>\n",
|
| 980 |
+
" <td>572</td>\n",
|
| 981 |
+
" <td>50</td>\n",
|
| 982 |
+
" <td>201</td>\n",
|
| 983 |
+
" <td>...</td>\n",
|
| 984 |
+
" <td>-36</td>\n",
|
| 985 |
+
" <td>-202</td>\n",
|
| 986 |
+
" <td>585</td>\n",
|
| 987 |
+
" <td>-4</td>\n",
|
| 988 |
+
" <td>0</td>\n",
|
| 989 |
+
" <td>645</td>\n",
|
| 990 |
+
" <td>109</td>\n",
|
| 991 |
+
" <td>0</td>\n",
|
| 992 |
+
" <td>600</td>\n",
|
| 993 |
+
" <td>157</td>\n",
|
| 994 |
" </tr>\n",
|
| 995 |
" <tr>\n",
|
| 996 |
" <th>7</th>\n",
|
| 997 |
+
" <td>-302</td>\n",
|
| 998 |
+
" <td>279</td>\n",
|
| 999 |
+
" <td>-2298</td>\n",
|
| 1000 |
+
" <td>-502</td>\n",
|
| 1001 |
+
" <td>282</td>\n",
|
| 1002 |
+
" <td>-1456</td>\n",
|
| 1003 |
+
" <td>-220</td>\n",
|
| 1004 |
+
" <td>409</td>\n",
|
| 1005 |
+
" <td>-362</td>\n",
|
| 1006 |
+
" <td>-12</td>\n",
|
| 1007 |
+
" <td>...</td>\n",
|
| 1008 |
+
" <td>-393</td>\n",
|
| 1009 |
+
" <td>512</td>\n",
|
| 1010 |
+
" <td>411</td>\n",
|
| 1011 |
+
" <td>-487</td>\n",
|
| 1012 |
+
" <td>-212</td>\n",
|
| 1013 |
+
" <td>460</td>\n",
|
| 1014 |
+
" <td>-595</td>\n",
|
| 1015 |
+
" <td>-122</td>\n",
|
| 1016 |
+
" <td>433</td>\n",
|
| 1017 |
+
" <td>-670</td>\n",
|
| 1018 |
" </tr>\n",
|
| 1019 |
" <tr>\n",
|
| 1020 |
" <th>8</th>\n",
|
| 1021 |
+
" <td>-114</td>\n",
|
| 1022 |
+
" <td>277</td>\n",
|
| 1023 |
+
" <td>-97</td>\n",
|
| 1024 |
+
" <td>2</td>\n",
|
| 1025 |
+
" <td>247</td>\n",
|
| 1026 |
+
" <td>-329</td>\n",
|
| 1027 |
+
" <td>-220</td>\n",
|
| 1028 |
+
" <td>284</td>\n",
|
| 1029 |
+
" <td>-602</td>\n",
|
| 1030 |
+
" <td>-122</td>\n",
|
| 1031 |
+
" <td>...</td>\n",
|
| 1032 |
+
" <td>-860</td>\n",
|
| 1033 |
+
" <td>222</td>\n",
|
| 1034 |
+
" <td>271</td>\n",
|
| 1035 |
+
" <td>-1227</td>\n",
|
| 1036 |
+
" <td>420</td>\n",
|
| 1037 |
+
" <td>253</td>\n",
|
| 1038 |
+
" <td>-1668</td>\n",
|
| 1039 |
+
" <td>-212</td>\n",
|
| 1040 |
+
" <td>303</td>\n",
|
| 1041 |
+
" <td>-1919</td>\n",
|
| 1042 |
" </tr>\n",
|
| 1043 |
" <tr>\n",
|
| 1044 |
" <th>9</th>\n",
|
| 1045 |
+
" <td>-210</td>\n",
|
| 1046 |
+
" <td>529</td>\n",
|
| 1047 |
+
" <td>-943</td>\n",
|
| 1048 |
+
" <td>102</td>\n",
|
| 1049 |
+
" <td>578</td>\n",
|
| 1050 |
+
" <td>-830</td>\n",
|
| 1051 |
+
" <td>-221</td>\n",
|
| 1052 |
+
" <td>577</td>\n",
|
| 1053 |
+
" <td>-859</td>\n",
|
| 1054 |
+
" <td>-211</td>\n",
|
| 1055 |
+
" <td>...</td>\n",
|
| 1056 |
+
" <td>-752</td>\n",
|
| 1057 |
+
" <td>-122</td>\n",
|
| 1058 |
+
" <td>636</td>\n",
|
| 1059 |
+
" <td>-592</td>\n",
|
| 1060 |
+
" <td>-21</td>\n",
|
| 1061 |
+
" <td>602</td>\n",
|
| 1062 |
+
" <td>-558</td>\n",
|
| 1063 |
+
" <td>-200</td>\n",
|
| 1064 |
+
" <td>573</td>\n",
|
| 1065 |
+
" <td>-505</td>\n",
|
| 1066 |
" </tr>\n",
|
| 1067 |
" <tr>\n",
|
| 1068 |
" <th>10</th>\n",
|
| 1069 |
+
" <td>-200</td>\n",
|
| 1070 |
+
" <td>320</td>\n",
|
| 1071 |
+
" <td>82</td>\n",
|
| 1072 |
+
" <td>121</td>\n",
|
| 1073 |
+
" <td>289</td>\n",
|
| 1074 |
+
" <td>58</td>\n",
|
| 1075 |
+
" <td>22</td>\n",
|
| 1076 |
+
" <td>336</td>\n",
|
| 1077 |
+
" <td>-26</td>\n",
|
| 1078 |
+
" <td>122</td>\n",
|
| 1079 |
+
" <td>...</td>\n",
|
| 1080 |
+
" <td>-106</td>\n",
|
| 1081 |
+
" <td>-302</td>\n",
|
| 1082 |
+
" <td>422</td>\n",
|
| 1083 |
+
" <td>-158</td>\n",
|
| 1084 |
+
" <td>-202</td>\n",
|
| 1085 |
+
" <td>415</td>\n",
|
| 1086 |
+
" <td>-143</td>\n",
|
| 1087 |
+
" <td>12</td>\n",
|
| 1088 |
+
" <td>416</td>\n",
|
| 1089 |
+
" <td>-340</td>\n",
|
| 1090 |
" </tr>\n",
|
| 1091 |
" <tr>\n",
|
| 1092 |
" <th>11</th>\n",
|
| 1093 |
+
" <td>-201</td>\n",
|
| 1094 |
+
" <td>612</td>\n",
|
| 1095 |
+
" <td>63</td>\n",
|
| 1096 |
+
" <td>-212</td>\n",
|
| 1097 |
+
" <td>604</td>\n",
|
| 1098 |
+
" <td>201</td>\n",
|
| 1099 |
+
" <td>-103</td>\n",
|
| 1100 |
+
" <td>620</td>\n",
|
| 1101 |
+
" <td>261</td>\n",
|
| 1102 |
+
" <td>22</td>\n",
|
| 1103 |
+
" <td>...</td>\n",
|
| 1104 |
+
" <td>250</td>\n",
|
| 1105 |
+
" <td>402</td>\n",
|
| 1106 |
+
" <td>616</td>\n",
|
| 1107 |
+
" <td>161</td>\n",
|
| 1108 |
+
" <td>-212</td>\n",
|
| 1109 |
+
" <td>559</td>\n",
|
| 1110 |
+
" <td>20</td>\n",
|
| 1111 |
+
" <td>-210</td>\n",
|
| 1112 |
+
" <td>547</td>\n",
|
| 1113 |
+
" <td>161</td>\n",
|
| 1114 |
" </tr>\n",
|
| 1115 |
" <tr>\n",
|
| 1116 |
" <th>12</th>\n",
|
| 1117 |
+
" <td>102</td>\n",
|
| 1118 |
+
" <td>578</td>\n",
|
| 1119 |
+
" <td>-830</td>\n",
|
| 1120 |
+
" <td>-221</td>\n",
|
| 1121 |
+
" <td>577</td>\n",
|
| 1122 |
+
" <td>-859</td>\n",
|
| 1123 |
+
" <td>-211</td>\n",
|
| 1124 |
+
" <td>579</td>\n",
|
| 1125 |
+
" <td>-752</td>\n",
|
| 1126 |
+
" <td>-122</td>\n",
|
| 1127 |
+
" <td>...</td>\n",
|
| 1128 |
+
" <td>-592</td>\n",
|
| 1129 |
+
" <td>-21</td>\n",
|
| 1130 |
+
" <td>602</td>\n",
|
| 1131 |
+
" <td>-558</td>\n",
|
| 1132 |
+
" <td>-200</td>\n",
|
| 1133 |
+
" <td>573</td>\n",
|
| 1134 |
+
" <td>-505</td>\n",
|
| 1135 |
+
" <td>222</td>\n",
|
| 1136 |
+
" <td>587</td>\n",
|
| 1137 |
+
" <td>-400</td>\n",
|
| 1138 |
" </tr>\n",
|
| 1139 |
" <tr>\n",
|
| 1140 |
" <th>13</th>\n",
|
| 1141 |
+
" <td>-2</td>\n",
|
| 1142 |
+
" <td>550</td>\n",
|
| 1143 |
+
" <td>736</td>\n",
|
| 1144 |
+
" <td>220</td>\n",
|
| 1145 |
+
" <td>531</td>\n",
|
| 1146 |
+
" <td>814</td>\n",
|
| 1147 |
+
" <td>-112</td>\n",
|
| 1148 |
+
" <td>527</td>\n",
|
| 1149 |
+
" <td>840</td>\n",
|
| 1150 |
+
" <td>320</td>\n",
|
| 1151 |
+
" <td>...</td>\n",
|
| 1152 |
+
" <td>906</td>\n",
|
| 1153 |
+
" <td>-221</td>\n",
|
| 1154 |
+
" <td>562</td>\n",
|
| 1155 |
+
" <td>1013</td>\n",
|
| 1156 |
+
" <td>-231</td>\n",
|
| 1157 |
+
" <td>563</td>\n",
|
| 1158 |
+
" <td>1342</td>\n",
|
| 1159 |
+
" <td>212</td>\n",
|
| 1160 |
+
" <td>546</td>\n",
|
| 1161 |
+
" <td>1557</td>\n",
|
| 1162 |
" </tr>\n",
|
| 1163 |
" <tr>\n",
|
| 1164 |
" <th>14</th>\n",
|
| 1165 |
+
" <td>-300</td>\n",
|
| 1166 |
+
" <td>554</td>\n",
|
| 1167 |
+
" <td>-130</td>\n",
|
| 1168 |
+
" <td>222</td>\n",
|
| 1169 |
+
" <td>598</td>\n",
|
| 1170 |
+
" <td>-85</td>\n",
|
| 1171 |
+
" <td>221</td>\n",
|
| 1172 |
+
" <td>581</td>\n",
|
| 1173 |
+
" <td>-249</td>\n",
|
| 1174 |
+
" <td>113</td>\n",
|
| 1175 |
+
" <td>...</td>\n",
|
| 1176 |
+
" <td>-242</td>\n",
|
| 1177 |
+
" <td>-220</td>\n",
|
| 1178 |
+
" <td>561</td>\n",
|
| 1179 |
+
" <td>-13</td>\n",
|
| 1180 |
+
" <td>-102</td>\n",
|
| 1181 |
+
" <td>601</td>\n",
|
| 1182 |
+
" <td>258</td>\n",
|
| 1183 |
+
" <td>-221</td>\n",
|
| 1184 |
+
" <td>575</td>\n",
|
| 1185 |
+
" <td>438</td>\n",
|
| 1186 |
" </tr>\n",
|
| 1187 |
" <tr>\n",
|
| 1188 |
" <th>15</th>\n",
|
| 1189 |
+
" <td>-322</td>\n",
|
| 1190 |
+
" <td>381</td>\n",
|
| 1191 |
+
" <td>-1133</td>\n",
|
| 1192 |
+
" <td>222</td>\n",
|
| 1193 |
+
" <td>413</td>\n",
|
| 1194 |
+
" <td>-1103</td>\n",
|
| 1195 |
+
" <td>223</td>\n",
|
| 1196 |
+
" <td>370</td>\n",
|
| 1197 |
+
" <td>-1289</td>\n",
|
| 1198 |
+
" <td>-520</td>\n",
|
| 1199 |
+
" <td>...</td>\n",
|
| 1200 |
+
" <td>-1204</td>\n",
|
| 1201 |
+
" <td>-320</td>\n",
|
| 1202 |
+
" <td>452</td>\n",
|
| 1203 |
+
" <td>-732</td>\n",
|
| 1204 |
+
" <td>-220</td>\n",
|
| 1205 |
+
" <td>465</td>\n",
|
| 1206 |
+
" <td>-473</td>\n",
|
| 1207 |
+
" <td>11</td>\n",
|
| 1208 |
+
" <td>425</td>\n",
|
| 1209 |
+
" <td>-396</td>\n",
|
| 1210 |
" </tr>\n",
|
| 1211 |
" <tr>\n",
|
| 1212 |
" <th>16</th>\n",
|
| 1213 |
+
" <td>-202</td>\n",
|
| 1214 |
+
" <td>316</td>\n",
|
| 1215 |
+
" <td>-1791</td>\n",
|
| 1216 |
+
" <td>-232</td>\n",
|
| 1217 |
+
" <td>333</td>\n",
|
| 1218 |
+
" <td>-1659</td>\n",
|
| 1219 |
+
" <td>-22</td>\n",
|
| 1220 |
+
" <td>421</td>\n",
|
| 1221 |
+
" <td>-1718</td>\n",
|
| 1222 |
+
" <td>-511</td>\n",
|
| 1223 |
+
" <td>...</td>\n",
|
| 1224 |
+
" <td>-1547</td>\n",
|
| 1225 |
+
" <td>201</td>\n",
|
| 1226 |
+
" <td>481</td>\n",
|
| 1227 |
+
" <td>-1213</td>\n",
|
| 1228 |
+
" <td>-220</td>\n",
|
| 1229 |
+
" <td>433</td>\n",
|
| 1230 |
+
" <td>-1375</td>\n",
|
| 1231 |
+
" <td>222</td>\n",
|
| 1232 |
+
" <td>404</td>\n",
|
| 1233 |
+
" <td>-1306</td>\n",
|
| 1234 |
" </tr>\n",
|
| 1235 |
" <tr>\n",
|
| 1236 |
" <th>17</th>\n",
|
| 1237 |
+
" <td>-203</td>\n",
|
| 1238 |
+
" <td>438</td>\n",
|
| 1239 |
+
" <td>-86</td>\n",
|
| 1240 |
+
" <td>-521</td>\n",
|
| 1241 |
+
" <td>436</td>\n",
|
| 1242 |
+
" <td>327</td>\n",
|
| 1243 |
+
" <td>-422</td>\n",
|
| 1244 |
+
" <td>453</td>\n",
|
| 1245 |
+
" <td>745</td>\n",
|
| 1246 |
+
" <td>-222</td>\n",
|
| 1247 |
+
" <td>...</td>\n",
|
| 1248 |
+
" <td>921</td>\n",
|
| 1249 |
+
" <td>211</td>\n",
|
| 1250 |
+
" <td>483</td>\n",
|
| 1251 |
+
" <td>813</td>\n",
|
| 1252 |
+
" <td>401</td>\n",
|
| 1253 |
+
" <td>492</td>\n",
|
| 1254 |
+
" <td>535</td>\n",
|
| 1255 |
+
" <td>220</td>\n",
|
| 1256 |
+
" <td>436</td>\n",
|
| 1257 |
+
" <td>318</td>\n",
|
| 1258 |
" </tr>\n",
|
| 1259 |
" <tr>\n",
|
| 1260 |
" <th>18</th>\n",
|
| 1261 |
+
" <td>724</td>\n",
|
| 1262 |
+
" <td>526</td>\n",
|
| 1263 |
+
" <td>-5020</td>\n",
|
| 1264 |
+
" <td>-412</td>\n",
|
| 1265 |
+
" <td>345</td>\n",
|
| 1266 |
+
" <td>-7138</td>\n",
|
| 1267 |
+
" <td>-532</td>\n",
|
| 1268 |
+
" <td>352</td>\n",
|
| 1269 |
+
" <td>-6875</td>\n",
|
| 1270 |
+
" <td>-453</td>\n",
|
| 1271 |
+
" <td>...</td>\n",
|
| 1272 |
+
" <td>-6739</td>\n",
|
| 1273 |
+
" <td>260</td>\n",
|
| 1274 |
+
" <td>301</td>\n",
|
| 1275 |
+
" <td>-6366</td>\n",
|
| 1276 |
+
" <td>-623</td>\n",
|
| 1277 |
+
" <td>318</td>\n",
|
| 1278 |
+
" <td>-5477</td>\n",
|
| 1279 |
+
" <td>-512</td>\n",
|
| 1280 |
+
" <td>357</td>\n",
|
| 1281 |
+
" <td>-3812</td>\n",
|
| 1282 |
" </tr>\n",
|
| 1283 |
" <tr>\n",
|
| 1284 |
" <th>19</th>\n",
|
| 1285 |
+
" <td>400</td>\n",
|
| 1286 |
+
" <td>503</td>\n",
|
| 1287 |
+
" <td>905</td>\n",
|
| 1288 |
+
" <td>502</td>\n",
|
| 1289 |
+
" <td>490</td>\n",
|
| 1290 |
+
" <td>564</td>\n",
|
| 1291 |
+
" <td>-121</td>\n",
|
| 1292 |
+
" <td>489</td>\n",
|
| 1293 |
+
" <td>299</td>\n",
|
| 1294 |
+
" <td>320</td>\n",
|
| 1295 |
+
" <td>...</td>\n",
|
| 1296 |
+
" <td>283</td>\n",
|
| 1297 |
+
" <td>-123</td>\n",
|
| 1298 |
+
" <td>478</td>\n",
|
| 1299 |
+
" <td>234</td>\n",
|
| 1300 |
+
" <td>22</td>\n",
|
| 1301 |
+
" <td>516</td>\n",
|
| 1302 |
+
" <td>433</td>\n",
|
| 1303 |
+
" <td>-220</td>\n",
|
| 1304 |
+
" <td>487</td>\n",
|
| 1305 |
+
" <td>741</td>\n",
|
| 1306 |
" </tr>\n",
|
| 1307 |
" </tbody>\n",
|
| 1308 |
"</table>\n",
|
| 1309 |
+
"<p>20 rows × 21 columns</p>\n",
|
| 1310 |
"</div>"
|
| 1311 |
],
|
| 1312 |
"text/plain": [
|
| 1313 |
+
" 0 1 2 3 4 5 6 7 8 9 ... 11 \\\n",
|
| 1314 |
+
"0 -200 732 257 211 746 312 -22 714 277 -202 ... 382 \n",
|
| 1315 |
+
"1 202 486 -547 -320 452 -505 -222 525 -178 -102 ... 22 \n",
|
| 1316 |
+
"2 -302 336 -443 -202 343 -257 -201 336 -206 121 ... -175 \n",
|
| 1317 |
+
"3 401 681 768 -212 705 660 220 712 694 401 ... 544 \n",
|
| 1318 |
+
"4 -222 525 -178 -102 616 22 -2 557 58 200 ... 50 \n",
|
| 1319 |
+
"5 21 405 -173 -111 427 -180 -200 377 -150 -110 ... -91 \n",
|
| 1320 |
+
"6 -102 616 22 -2 557 58 200 572 50 201 ... -36 \n",
|
| 1321 |
+
"7 -302 279 -2298 -502 282 -1456 -220 409 -362 -12 ... -393 \n",
|
| 1322 |
+
"8 -114 277 -97 2 247 -329 -220 284 -602 -122 ... -860 \n",
|
| 1323 |
+
"9 -210 529 -943 102 578 -830 -221 577 -859 -211 ... -752 \n",
|
| 1324 |
+
"10 -200 320 82 121 289 58 22 336 -26 122 ... -106 \n",
|
| 1325 |
+
"11 -201 612 63 -212 604 201 -103 620 261 22 ... 250 \n",
|
| 1326 |
+
"12 102 578 -830 -221 577 -859 -211 579 -752 -122 ... -592 \n",
|
| 1327 |
+
"13 -2 550 736 220 531 814 -112 527 840 320 ... 906 \n",
|
| 1328 |
+
"14 -300 554 -130 222 598 -85 221 581 -249 113 ... -242 \n",
|
| 1329 |
+
"15 -322 381 -1133 222 413 -1103 223 370 -1289 -520 ... -1204 \n",
|
| 1330 |
+
"16 -202 316 -1791 -232 333 -1659 -22 421 -1718 -511 ... -1547 \n",
|
| 1331 |
+
"17 -203 438 -86 -521 436 327 -422 453 745 -222 ... 921 \n",
|
| 1332 |
+
"18 724 526 -5020 -412 345 -7138 -532 352 -6875 -453 ... -6739 \n",
|
| 1333 |
+
"19 400 503 905 502 490 564 -121 489 299 320 ... 283 \n",
|
| 1334 |
+
"\n",
|
| 1335 |
+
" 12 13 14 15 16 17 18 19 20 \n",
|
| 1336 |
+
"0 -221 703 505 200 711 556 111 702 536 \n",
|
| 1337 |
+
"1 -2 557 58 200 572 50 201 584 -36 \n",
|
| 1338 |
+
"2 -201 357 -235 21 392 -205 -222 412 -343 \n",
|
| 1339 |
+
"3 -202 644 372 202 625 446 222 643 403 \n",
|
| 1340 |
+
"4 201 584 -36 -202 585 -4 0 645 109 \n",
|
| 1341 |
+
"5 -12 316 -98 -200 356 -136 211 335 -157 \n",
|
| 1342 |
+
"6 -202 585 -4 0 645 109 0 600 157 \n",
|
| 1343 |
+
"7 512 411 -487 -212 460 -595 -122 433 -670 \n",
|
| 1344 |
+
"8 222 271 -1227 420 253 -1668 -212 303 -1919 \n",
|
| 1345 |
+
"9 -122 636 -592 -21 602 -558 -200 573 -505 \n",
|
| 1346 |
+
"10 -302 422 -158 -202 415 -143 12 416 -340 \n",
|
| 1347 |
+
"11 402 616 161 -212 559 20 -210 547 161 \n",
|
| 1348 |
+
"12 -21 602 -558 -200 573 -505 222 587 -400 \n",
|
| 1349 |
+
"13 -221 562 1013 -231 563 1342 212 546 1557 \n",
|
| 1350 |
+
"14 -220 561 -13 -102 601 258 -221 575 438 \n",
|
| 1351 |
+
"15 -320 452 -732 -220 465 -473 11 425 -396 \n",
|
| 1352 |
+
"16 201 481 -1213 -220 433 -1375 222 404 -1306 \n",
|
| 1353 |
+
"17 211 483 813 401 492 535 220 436 318 \n",
|
| 1354 |
+
"18 260 301 -6366 -623 318 -5477 -512 357 -3812 \n",
|
| 1355 |
+
"19 -123 478 234 22 516 433 -220 487 741 \n",
|
| 1356 |
+
"\n",
|
| 1357 |
+
"[20 rows x 21 columns]"
|
| 1358 |
]
|
| 1359 |
},
|
| 1360 |
+
"execution_count": 31,
|
| 1361 |
"metadata": {},
|
| 1362 |
"output_type": "execute_result"
|
| 1363 |
}
|
| 1364 |
],
|
| 1365 |
"source": [
|
| 1366 |
+
"#dgID.apply(lambda df: df[xyz].values.reshape(1,21)).reset_index()\n",
|
| 1367 |
+
"dgID.apply(lambda df: pd.Series(df[xyz].values[::-1].reshape(1,-1)[0])).reset_index().iloc[:,1:]"
|
| 1368 |
]
|
| 1369 |
},
|
| 1370 |
{
|
| 1371 |
"cell_type": "code",
|
| 1372 |
+
"execution_count": null,
|
| 1373 |
"metadata": {},
|
| 1374 |
"outputs": [
|
| 1375 |
{
|