f64 commited on
Commit
ed3ce54
·
1 Parent(s): 2e745f7
Files changed (2) hide show
  1. pages/8_Chat.py +3 -3
  2. static/test.ipynb +291 -6
pages/8_Chat.py CHANGED
@@ -2,7 +2,7 @@ import os, re, sys, time, math, shutil, urllib, string, random, pickle, zipfile,
2
  import streamlit as st, pandas as pd, numpy as np
3
  import my_static_methods as my_stm
4
  from faker import Faker
5
- st.markdown(my_stm.STYLE_CORRECTION, unsafe_allow_html=True)
6
  st.sidebar.markdown("# Переговоры 💬")
7
 
8
  fake = Faker()
@@ -14,5 +14,5 @@ if prompt := st.chat_input("Спрашивайте тут : "):
14
  answer = prompt[::-1]
15
  strEnFakeText = fake.paragraph(nb_sentences=4, variable_nb_sentences=False)
16
  strRuFakeText = fakeRU.paragraph(nb_sentences=4, variable_nb_sentences=False)
17
- answer = f"{datetime.datetime.now():%d.%m.%Y %H:%M:%S}\n {strEnFakeText}\n {strRuFakeText}"
18
- messages.chat_message("boss").write(f"{answer}") # assistant
 
2
  import streamlit as st, pandas as pd, numpy as np
3
  import my_static_methods as my_stm
4
  from faker import Faker
5
+ st.html(my_stm.STYLE_CORRECTION)
6
  st.sidebar.markdown("# Переговоры 💬")
7
 
8
  fake = Faker()
 
14
  answer = prompt[::-1]
15
  strEnFakeText = fake.paragraph(nb_sentences=4, variable_nb_sentences=False)
16
  strRuFakeText = fakeRU.paragraph(nb_sentences=4, variable_nb_sentences=False)
17
+ answer = f"{datetime.datetime.now():%d.%m.%Y %H:%M:%S} \n {strEnFakeText} \n {strRuFakeText}"
18
+ messages.chat_message("ai").write(f"{answer}") # assistant
static/test.ipynb CHANGED
@@ -2,7 +2,7 @@
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
- "execution_count": 7,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
@@ -16,9 +16,19 @@
16
  },
17
  {
18
  "cell_type": "code",
19
- "execution_count": 8,
20
  "metadata": {},
21
  "outputs": [
 
 
 
 
 
 
 
 
 
 
22
  {
23
  "data": {
24
  "text/html": [
@@ -218,7 +228,7 @@
218
  "[12010 rows x 10 columns]"
219
  ]
220
  },
221
- "execution_count": 8,
222
  "metadata": {},
223
  "output_type": "execute_result"
224
  }
@@ -230,7 +240,7 @@
230
  " df = pd.read_csv(path1, sep=';',compression=\"zip\")\n",
231
  "if not df is None:\n",
232
  " df0 = df.copy()\n",
233
- " df0[\"Vis\"] = df0.V.map(lambda v: 0 if v is np.NaN else 1).astype(int)\n",
234
  " df0[\"Vfloat\"] = df0.V.map(lambda v: 0 if str(v)==\"nan\" else str(v).replace(',', '.')).astype(float)\n",
235
  " df0[\"Vsign\"] = df0.Vfloat.map(lambda v: -1 if v<0 else 1 if v>0 else 0).astype(int)\n",
236
  " df0[\"Vposneg\"] = df0.Vfloat.map(lambda v: \"n\" if v<0 else \"p\" if v>0 else \"o\").astype(str)\n",
@@ -239,7 +249,7 @@
239
  },
240
  {
241
  "cell_type": "code",
242
- "execution_count": 17,
243
  "metadata": {},
244
  "outputs": [
245
  {
@@ -257,6 +267,281 @@
257
  " fileXYZ = f\"{colnames}_{colcounts}.CSV\"\n",
258
  " write(fileXYZ)"
259
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  }
261
  ],
262
  "metadata": {
@@ -275,7 +560,7 @@
275
  "name": "python",
276
  "nbconvert_exporter": "python",
277
  "pygments_lexer": "ipython3",
278
- "version": "3.9.7"
279
  }
280
  },
281
  "nbformat": 4,
 
2
  "cells": [
3
  {
4
  "cell_type": "code",
5
+ "execution_count": 2,
6
  "metadata": {},
7
  "outputs": [],
8
  "source": [
 
16
  },
17
  {
18
  "cell_type": "code",
19
+ "execution_count": 4,
20
  "metadata": {},
21
  "outputs": [
22
+ {
23
+ "name": "stderr",
24
+ "output_type": "stream",
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_6328\\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
+ },
32
  {
33
  "data": {
34
  "text/html": [
 
228
  "[12010 rows x 10 columns]"
229
  ]
230
  },
231
+ "execution_count": 4,
232
  "metadata": {},
233
  "output_type": "execute_result"
234
  }
 
240
  " df = pd.read_csv(path1, sep=';',compression=\"zip\")\n",
241
  "if not df is None:\n",
242
  " df0 = df.copy()\n",
243
+ " df0[\"Vis\"] = df0.V.map(lambda v: 0 if str(v)==\"nan\" else 1).astype(int)\n",
244
  " df0[\"Vfloat\"] = df0.V.map(lambda v: 0 if str(v)==\"nan\" else str(v).replace(',', '.')).astype(float)\n",
245
  " df0[\"Vsign\"] = df0.Vfloat.map(lambda v: -1 if v<0 else 1 if v>0 else 0).astype(int)\n",
246
  " df0[\"Vposneg\"] = df0.Vfloat.map(lambda v: \"n\" if v<0 else \"p\" if v>0 else \"o\").astype(str)\n",
 
249
  },
250
  {
251
  "cell_type": "code",
252
+ "execution_count": 5,
253
  "metadata": {},
254
  "outputs": [
255
  {
 
267
  " fileXYZ = f\"{colnames}_{colcounts}.CSV\"\n",
268
  " write(fileXYZ)"
269
  ]
270
+ },
271
+ {
272
+ "cell_type": "code",
273
+ "execution_count": 13,
274
+ "metadata": {},
275
+ "outputs": [
276
+ {
277
+ "data": {
278
+ "text/html": [
279
+ "<div>\n",
280
+ "<style scoped>\n",
281
+ " .dataframe tbody tr th:only-of-type {\n",
282
+ " vertical-align: middle;\n",
283
+ " }\n",
284
+ "\n",
285
+ " .dataframe tbody tr th {\n",
286
+ " vertical-align: top;\n",
287
+ " }\n",
288
+ "\n",
289
+ " .dataframe thead th {\n",
290
+ " text-align: right;\n",
291
+ " }\n",
292
+ "</style>\n",
293
+ "<table border=\"1\" class=\"dataframe\">\n",
294
+ " <thead>\n",
295
+ " <tr style=\"text-align: right;\">\n",
296
+ " <th></th>\n",
297
+ " <th>ID</th>\n",
298
+ " <th>X</th>\n",
299
+ " <th>Y</th>\n",
300
+ " <th>Z</th>\n",
301
+ " </tr>\n",
302
+ " </thead>\n",
303
+ " <tbody>\n",
304
+ " <tr>\n",
305
+ " <th>0</th>\n",
306
+ " <td>AAA011111</td>\n",
307
+ " <td>111.0</td>\n",
308
+ " <td>702.0</td>\n",
309
+ " <td>536.0</td>\n",
310
+ " </tr>\n",
311
+ " <tr>\n",
312
+ " <th>1</th>\n",
313
+ " <td>AAA011111</td>\n",
314
+ " <td>200.0</td>\n",
315
+ " <td>711.0</td>\n",
316
+ " <td>556.0</td>\n",
317
+ " </tr>\n",
318
+ " <tr>\n",
319
+ " <th>2</th>\n",
320
+ " <td>AAA011111</td>\n",
321
+ " <td>-221.0</td>\n",
322
+ " <td>703.0</td>\n",
323
+ " <td>505.0</td>\n",
324
+ " </tr>\n",
325
+ " <tr>\n",
326
+ " <th>3</th>\n",
327
+ " <td>AAA011111</td>\n",
328
+ " <td>-202.0</td>\n",
329
+ " <td>660.0</td>\n",
330
+ " <td>382.0</td>\n",
331
+ " </tr>\n",
332
+ " <tr>\n",
333
+ " <th>4</th>\n",
334
+ " <td>AAA011111</td>\n",
335
+ " <td>-22.0</td>\n",
336
+ " <td>714.0</td>\n",
337
+ " <td>277.0</td>\n",
338
+ " </tr>\n",
339
+ " <tr>\n",
340
+ " <th>5</th>\n",
341
+ " <td>AAA011111</td>\n",
342
+ " <td>211.0</td>\n",
343
+ " <td>746.0</td>\n",
344
+ " <td>312.0</td>\n",
345
+ " </tr>\n",
346
+ " <tr>\n",
347
+ " <th>6</th>\n",
348
+ " <td>AAA011111</td>\n",
349
+ " <td>-200.0</td>\n",
350
+ " <td>732.0</td>\n",
351
+ " <td>257.0</td>\n",
352
+ " </tr>\n",
353
+ " <tr>\n",
354
+ " <th>7</th>\n",
355
+ " <td>NaN</td>\n",
356
+ " <td>NaN</td>\n",
357
+ " <td>NaN</td>\n",
358
+ " <td>NaN</td>\n",
359
+ " </tr>\n",
360
+ " <tr>\n",
361
+ " <th>8</th>\n",
362
+ " <td>AAA011112</td>\n",
363
+ " <td>201.0</td>\n",
364
+ " <td>584.0</td>\n",
365
+ " <td>-36.0</td>\n",
366
+ " </tr>\n",
367
+ " <tr>\n",
368
+ " <th>9</th>\n",
369
+ " <td>AAA011112</td>\n",
370
+ " <td>200.0</td>\n",
371
+ " <td>572.0</td>\n",
372
+ " <td>50.0</td>\n",
373
+ " </tr>\n",
374
+ " <tr>\n",
375
+ " <th>10</th>\n",
376
+ " <td>AAA011112</td>\n",
377
+ " <td>-2.0</td>\n",
378
+ " <td>557.0</td>\n",
379
+ " <td>58.0</td>\n",
380
+ " </tr>\n",
381
+ " <tr>\n",
382
+ " <th>11</th>\n",
383
+ " <td>AAA011112</td>\n",
384
+ " <td>-102.0</td>\n",
385
+ " <td>616.0</td>\n",
386
+ " <td>22.0</td>\n",
387
+ " </tr>\n",
388
+ " <tr>\n",
389
+ " <th>12</th>\n",
390
+ " <td>AAA011112</td>\n",
391
+ " <td>-222.0</td>\n",
392
+ " <td>525.0</td>\n",
393
+ " <td>-178.0</td>\n",
394
+ " </tr>\n",
395
+ " <tr>\n",
396
+ " <th>13</th>\n",
397
+ " <td>AAA011112</td>\n",
398
+ " <td>-320.0</td>\n",
399
+ " <td>452.0</td>\n",
400
+ " <td>-505.0</td>\n",
401
+ " </tr>\n",
402
+ " <tr>\n",
403
+ " <th>14</th>\n",
404
+ " <td>AAA011112</td>\n",
405
+ " <td>202.0</td>\n",
406
+ " <td>486.0</td>\n",
407
+ " <td>-547.0</td>\n",
408
+ " </tr>\n",
409
+ " <tr>\n",
410
+ " <th>15</th>\n",
411
+ " <td>NaN</td>\n",
412
+ " <td>NaN</td>\n",
413
+ " <td>NaN</td>\n",
414
+ " <td>NaN</td>\n",
415
+ " </tr>\n",
416
+ " </tbody>\n",
417
+ "</table>\n",
418
+ "</div>"
419
+ ],
420
+ "text/plain": [
421
+ " ID X Y Z\n",
422
+ "0 AAA011111 111.0 702.0 536.0\n",
423
+ "1 AAA011111 200.0 711.0 556.0\n",
424
+ "2 AAA011111 -221.0 703.0 505.0\n",
425
+ "3 AAA011111 -202.0 660.0 382.0\n",
426
+ "4 AAA011111 -22.0 714.0 277.0\n",
427
+ "5 AAA011111 211.0 746.0 312.0\n",
428
+ "6 AAA011111 -200.0 732.0 257.0\n",
429
+ "7 NaN NaN NaN NaN\n",
430
+ "8 AAA011112 201.0 584.0 -36.0\n",
431
+ "9 AAA011112 200.0 572.0 50.0\n",
432
+ "10 AAA011112 -2.0 557.0 58.0\n",
433
+ "11 AAA011112 -102.0 616.0 22.0\n",
434
+ "12 AAA011112 -222.0 525.0 -178.0\n",
435
+ "13 AAA011112 -320.0 452.0 -505.0\n",
436
+ "14 AAA011112 202.0 486.0 -547.0\n",
437
+ "15 NaN NaN NaN NaN"
438
+ ]
439
+ },
440
+ "execution_count": 13,
441
+ "metadata": {},
442
+ "output_type": "execute_result"
443
+ }
444
+ ],
445
+ "source": [
446
+ "path2 = r\"J:\\tmp\\Makarov\\Pack_01.csv\"\n",
447
+ "df2 = None\n",
448
+ "if(os.path.exists(path2)):\n",
449
+ " df2 = pd.read_csv(path2, sep=';', header=None)\n",
450
+ " df2.columns = [\"ID\",\"X\",\"Y\",\"Z\"]\n",
451
+ "#df2.groupby(\"id\").index\n",
452
+ "df2.head(16)"
453
+ ]
454
+ },
455
+ {
456
+ "cell_type": "code",
457
+ "execution_count": 36,
458
+ "metadata": {},
459
+ "outputs": [
460
+ {
461
+ "name": "stdout",
462
+ "output_type": "stream",
463
+ "text": [
464
+ "set(df2.groupby(\"ID\").apply(len))={14, 7}\n"
465
+ ]
466
+ },
467
+ {
468
+ "name": "stderr",
469
+ "output_type": "stream",
470
+ "text": [
471
+ "C:\\Users\\f64\\AppData\\Local\\Temp\\ipykernel_6328\\1271425466.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",
472
+ " print(f\"{set(df2.groupby(\"ID\").apply(len))=}\")\n",
473
+ "C:\\Users\\f64\\AppData\\Local\\Temp\\ipykernel_6328\\1271425466.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",
474
+ " df2.groupby(\"ID\").apply(len)\n"
475
+ ]
476
+ },
477
+ {
478
+ "data": {
479
+ "text/plain": [
480
+ "ID\n",
481
+ "AAA011111 7\n",
482
+ "AAA011112 7\n",
483
+ "AAA011113 7\n",
484
+ "AAA011114 7\n",
485
+ "AAA011115 7\n",
486
+ "AAA011116 7\n",
487
+ "AAA011117 7\n",
488
+ "AAA011118 7\n",
489
+ "BBB011111 7\n",
490
+ "BBB011112 14\n",
491
+ "BBB011113 7\n",
492
+ "BBB011114 7\n",
493
+ "BBB011115 7\n",
494
+ "BBB011116 7\n",
495
+ "CCC011111 7\n",
496
+ "CCC011112 7\n",
497
+ "DDD011111 7\n",
498
+ "DDD011112 7\n",
499
+ "DDD011113 7\n",
500
+ "dtype: int64"
501
+ ]
502
+ },
503
+ "execution_count": 36,
504
+ "metadata": {},
505
+ "output_type": "execute_result"
506
+ }
507
+ ],
508
+ "source": [
509
+ "print(f\"{set(df2.groupby(\"ID\").apply(len))=}\")\n",
510
+ "df2.groupby(\"ID\").apply(len)"
511
+ ]
512
+ },
513
+ {
514
+ "cell_type": "code",
515
+ "execution_count": 34,
516
+ "metadata": {},
517
+ "outputs": [
518
+ {
519
+ "name": "stderr",
520
+ "output_type": "stream",
521
+ "text": [
522
+ "C:\\Users\\f64\\AppData\\Local\\Temp\\ipykernel_6328\\3316428820.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",
523
+ " set(df2.groupby(\"ID\").apply(len))\n"
524
+ ]
525
+ },
526
+ {
527
+ "data": {
528
+ "text/plain": [
529
+ "{7, 14}"
530
+ ]
531
+ },
532
+ "execution_count": 34,
533
+ "metadata": {},
534
+ "output_type": "execute_result"
535
+ }
536
+ ],
537
+ "source": [
538
+ "#df2.groupby(\"ID\").apply(lambda df: df.tail(1))\n",
539
+ "#df2.groupby(\"ID\").apply(lambda df: type(df))\n",
540
+ "#set(df2.groupby(\"ID\").apply(lambda df: len(df)).values)\n",
541
+ "\n",
542
+ "#df2.groupby(\"ID\").apply(lambda df: list(df.columns))\n",
543
+ "#df2.groupby(\"ID\").apply(lambda df: list(df.columns))"
544
+ ]
545
  }
546
  ],
547
  "metadata": {
 
560
  "name": "python",
561
  "nbconvert_exporter": "python",
562
  "pygments_lexer": "ipython3",
563
+ "version": "3.12.4"
564
  }
565
  },
566
  "nbformat": 4,