I have a data table derived via unstacking an existing dataframe:
Day 0 1 2 3 4 5 6
Hrs
0 223 231 135 122 099 211 217
1 156 564 132 414 156 454 157
2 950 178 121 840 143 648 192
3 025 975 151 185 341 145 888
4 111 264 469 330 671 201 345
-- -- -- -- -- -- -- --
I want to simply change the column titles so I have the days of the week displayed instead of numbered. Something like this:
Day Mon Tue Wed Thu Fri Sat Sun
Hrs
0 223 231 135 122 099 211 217
1 156 564 132 414 156 454 157
2 950 178 121 840 143 648 192
3 025 975 151 185 341 145 888
4 111 264 469 330 671 201 345
-- -- -- -- -- -- -- --
I've tried .rename(columns = {'original':'new', etc}, inplace = True) and other similar functions, none of which have worked.
I also tried going to the original dataframe and creating a dt.day_name column from the parsed dates, but it come out with the days of the week mixed up.
I'm sure it's a simple fix, but I'm living off nothing but caffeine, so help would be appreciated.
You can try:
import pandas as pd
df = pd.DataFrame(columns=[0,1,2,3,4,5,6])
df.columns = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
I used the website diagrams.net to create a figure with some mathematical expressions. Of course, I can export it how PNG and import it to my Overleaf, but I want to retain the vectorization of the expressions. Because of that, I am trying to import it how PDF inside my Overleaf document.
When I use:
\begin{figure}[tbp!]
\centering
\includegraphics[width=\linewidth]{images/math_structure.pdf}
\caption{My figure description.}
\label{fig:math_structure}
\end{figure}
My figure is shown normally, aparently, but when I zoom in the mathematical expressions I have it:
Another interesting thing I noted is that when I download the PDF from Overleaf and open it using MUPDF the "bold" disappears, but when I open it using Google Chrome or Firefox the "bold" is there yet.
This is a pretty strange thing because I guess it was a problem of embedding font inside the PDF, but my file opens normally in MUPDF. Does anyone know what is happening and how can I resolve it?
I am sharing the math_structure in order to reproduce the problem in the following link: PDF
As an addendum to K J's answer:
looking at each letter there are two objects so although I can not see the shadow within the editor but accept it is there so it must be placed by the text outline generator? here I have moved and coloured some glyphs so the second edge is deliberate but most viewers would not show them as a "GLOW"
Indeed, all those items with a glow are drawn twice in the content stream, once for filling the defining path, once for stroking. E.g. the capital S of "State":
.111484379 0 0 -.111468516 140.764496 314.20746 cm
/G3 gs
55 507 m
55 562.33331 74 609 112 647 c
150 685 193.66666 704 243 704 c
257 704 l
313.66666 704 363 683 405 641 c
426 672 l
429.33334 676.66669 432.66666 681.66669 436 687 c
439.33334 692.33331 442.66666 696.66669 446 700 c
449 704 l
449.66666 704 451 704 453 704 c
455 704 457 704.33331 459 705 c
463 705 l
465 705 468 703 472 699 c
472 462 l
466 456 l
448 456 l
440.66666 456 436.33334 457 435 459 c
433.66666 461 432 467.66666 430 479 c
418.66666 563 385 618.66669 329 646 c
304.33334 656.66669 279.33334 662 254 662 c
218.66666 662 190 650 168 626 c
146 602 135 574 135 542 c
135 519.33331 140.666672 498.66666 152 480 c
163.333328 461.33334 179.33333 446.33334 200 435 c
206.66667 432.33334 235.33333 424.66666 286 412 c
336.66666 399.33334 364.66666 391.66666 370 389 c
408 374.33334 439 349.33334 463 314 c
487 278.66666 499.33334 237.66667 500 191 c
500 137 482.66666 88.333336 448 45 c
413.33334 1.66666412 364.33334 -20.333334 301 -21 c
263.66666 -21 230.33333 -15.333334 201 -4 c
171.66667 7.333334 151.333328 17.666666 140 27 c
122 41 l
119.333336 37.666668 114.333336 31 107 21 c
99.666664 11 93 1.66666698 87 -7 c
81 -15.666667 78 -20.333334 78 -21 c
76.666664 -21.666666 73.333336 -22 68 -22 c
64 -22 l
62 -22 59 -20 55 -16 c
55 101 l
55 180.33334 55.333332 220.66667 56 222 c
57.333332 225.33333 64 227 76 227 c
89 227 l
93 223 95 218.66667 95 214 c
95 192.66667 98.333336 171.66667 105 151 c
111.666664 130.333328 123 110 139 90 c
155 70 177 54 205 42 c
233 30 266.33334 24 305 24 c
336.33334 24 363.33334 36.666664 386 62 c
408.66666 87.333336 420 118.333328 420 155 c
420 183.66667 412.66666 209.66667 398 233 c
383.33334 256.33334 364 272.33334 340 281 c
302.66666 290.33334 278 296.66666 266 300 c
262.66666 300.66666 253.66667 302.66666 239 306 c
224.33333 309.33334 213.33333 312 206 314 c
198.66667 316 188 319.66666 174 325 c
160 330.33334 149 336.33334 141 343 c
133 349.66666 123.333336 357.66666 112 367 c
100.666664 376.33334 91.666664 388 85 402 c
65 434.66666 55 469.66666 55 507 c
h
f
/G7 gs
55 507 m
55 562.33331 74 609 112 647 c
150 685 193.66666 704 243 704 c
257 704 l
313.66666 704 363 683 405 641 c
426 672 l
429.33334 676.66669 432.66666 681.66669 436 687 c
439.33334 692.33331 442.66666 696.66669 446 700 c
449 704 l
449.66666 704 451 704 453 704 c
455 704 457 704.33331 459 705 c
463 705 l
465 705 468 703 472 699 c
472 462 l
466 456 l
448 456 l
440.66666 456 436.33334 457 435 459 c
433.66666 461 432 467.66666 430 479 c
418.66666 563 385 618.66669 329 646 c
304.33334 656.66669 279.33334 662 254 662 c
218.66666 662 190 650 168 626 c
146 602 135 574 135 542 c
135 519.33331 140.666672 498.66666 152 480 c
163.333328 461.33334 179.33333 446.33334 200 435 c
206.66667 432.33334 235.33333 424.66666 286 412 c
336.66666 399.33334 364.66666 391.66666 370 389 c
408 374.33334 439 349.33334 463 314 c
487 278.66666 499.33334 237.66667 500 191 c
500 137 482.66666 88.333336 448 45 c
413.33334 1.66666412 364.33334 -20.333334 301 -21 c
263.66666 -21 230.33333 -15.333334 201 -4 c
171.66667 7.333334 151.333328 17.666666 140 27 c
122 41 l
119.333336 37.666668 114.333336 31 107 21 c
99.666664 11 93 1.66666698 87 -7 c
81 -15.666667 78 -20.333334 78 -21 c
76.666664 -21.666666 73.333336 -22 68 -22 c
64 -22 l
62 -22 59 -20 55 -16 c
55 101 l
55 180.33334 55.333332 220.66667 56 222 c
57.333332 225.33333 64 227 76 227 c
89 227 l
93 223 95 218.66667 95 214 c
95 192.66667 98.333336 171.66667 105 151 c
111.666664 130.333328 123 110 139 90 c
155 70 177 54 205 42 c
233 30 266.33334 24 305 24 c
336.33334 24 363.33334 36.666664 386 62 c
408.66666 87.333336 420 118.333328 420 155 c
420 183.66667 412.66666 209.66667 398 233 c
383.33334 256.33334 364 272.33334 340 281 c
302.66666 290.33334 278 296.66666 266 300 c
262.66666 300.66666 253.66667 302.66666 239 306 c
224.33333 309.33334 213.33333 312 206 314 c
198.66667 316 188 319.66666 174 325 c
160 330.33334 149 336.33334 141 343 c
133 349.66666 123.333336 357.66666 112 367 c
100.666664 376.33334 91.666664 388 85 402 c
65 434.66666 55 469.66666 55 507 c
h
S
The filled version is drawn with the extended graphics state G3, the stroked version is drawn with the extended graphics state G7.
G3 fills in an opaque manner:
<</BM/Normal/ca 1>
but G7 strokes very transparently (opacity .1098) and sets some other parameters:
<</BM/Normal/CA .1098/LC 0/LJ 0/LW 0/ML 4/SA true/ca .1098>>
But in particular G7 also sets the line width to 0 (the thinnest line that can be rendered at device resolution: 1 device pixel wide).
The OP mentions that they see the shadows when they zoom in. Thus, maybe those viewers in which you see a broad shadow/glow after zooming do simply zoom by drawing everything magnified by the zoom factor, i.e. the shadow/glow becomes zoom factor * 1 pixel wide; and those viewers in which you don't see a broad shadow/glow draw the outlines even after zooming with a 1 pixel width.
It does not appear to be the difference is in the font style since the weighting between standard 24 and bold 24 is shown below on the right. Which is not evident in your two samples.
However, what is noticeable in your sample is the "shadows" around each of those letter on the left giving the impression of extra thickness.
Initially I would expect that could be caused by the difference between jpeg (haloed lettering) and png (crisp anti-alias outlines). But then the shadow is too regular i.e. not uneven like it would normally be in a jpeg.
At this stage it looks like there may be some other reason for such fuzzy fonts.
Without a sample I would have to guess the PDF has potentially a font with an alpha component but could be way off in such a wild assumption.
Later Edit
Thanks for your link but the mystery deepens, since that linked PDF in Chromium Edge even enlarged shows no evidence of any shadows, but then again the maths looks like vector outlines only the middle Tahoma appears to be font and the one embedded, as generated by Skia/PDF thus built by chrome?.
I have to agree there is some other influence somewhere down the line but the browser should not affect the PDF unless it adds or respects some overlay based on an extra component, and looking at each letter there are two objects so although I can not see the shadow within the editor but accept it is there so it must be placed by the text outline generator?
here I have moved and coloured some glyphs so the second edge is deliberate but most viewers would not show them as a "GLOW"
You mentioned "diagrams.net" which does have many shadow options but I never experienced any other than deliberately set to right and down. Perhaps look for a rogue setting there.
In summary the file is declared as compatible with version 1.4 (may have transparency) and clearly some transparent objects have been included around each letter! but not in a fashion expected by all viewers. As a result of #mkl 's observation I retested the pdf in many viewers with the settings that could have an effect such as vector line thickening in acrobat, However NONE I tested showed the extra thick outlines, thus the PDF seems valid but some PDF viewer(apps) methods you are using seem to thicken the anti-alias much more than should be expected for a single pixel boundary.
I am running a model in GAMS with a number of variables with 2 dimensions, calling the indexes i and j respectively. I have a few constraints relating to just the "diagonal" entries, so I coded them something like "d(i,i)", but GAMS gives error 171 when I do this, for example the first error comes on equation e3. How do I express this in GAMS? Code follows:
Set
i 'Origin' / 1*20 /
j 'Destination' / 1*20 /;
Table A(i,j)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
1 0 4 2 574 481 440 408 633 573 1066 486 1926 1537 183 334 374 107 509 378 499
2 4 0 2 573 480 438 412 632 572 1064 484 1924 1535 182 332 372 111 508 377 498
3 3 2 0 572 479 437 411 631 571 1063 484 1923 1534 181 332 371 109 507 376 497
4 574 572 572 0 93 249 135 1188 1128 1620 1040 2480 2091 737 888 928 683 498 367 488
5 481 480 479 93 0 156 228 1095 1035 1527 948 2387 1998 645 796 836 591 406 275 396
6 440 438 437 249 156 0 384 1053 993 1485 906 2345 1956 603 754 794 549 364 233 354
7 409 412 411 135 228 384 0 1044 984 1476 897 2336 1947 594 745 785 302 633 502 623
8 633 632 631 1188 1095 1053 1044 0 532 1024 623 1246 792 450 300 403 742 560 992 668
9 573 572 571 1128 1035 993 984 532 0 494 326 879 424 392 385 207 682 1063 932 1053
10 1066 1064 1063 1620 1527 1485 1476 1024 494 0 820 1979 823 885 878 699 1175 1555 1424 1545
11 486 484 484 1040 948 906 897 623 326 820 0 724 270 359 477 223 595 975 844 966
12 1926 1924 1923 2480 2387 2345 2336 1246 878 1979 724 0 454 1943 1099 846 2035 2415 2284 2405
13 1537 1535 1534 2091 1998 1956 1947 792 424 823 270 454 0 1554 645 392 1646 2026 1895 2016
14 183 182 181 738 645 603 594 450 392 884 359 1943 1554 0 151 192 292 672 542 663
15 334 332 332 888 796 754 745 300 385 878 477 1099 645 151 0 257 443 261 692 369
16 373 372 371 928 835 793 784 403 207 699 223 846 392 192 256 0 482 863 732 853
17 107 111 109 683 591 549 302 742 683 1175 595 2035 1646 292 443 483 0 618 487 608
18 509 507 507 498 406 364 633 560 1063 1555 975 2415 2026 672 261 863 618 0 134 180
19 378 377 376 367 275 233 502 992 932 1424 844 2284 1895 542 692 732 487 134 0 122
20 500 498 497 489 396 354 624 668 1053 1545 966 2405 2016 663 369 854 609 180 122 0
;
Positive variable c(i,j) 'cost direct';
Positive variable cstar(i,j) 'cost routing';
Positive variable z 'objective';
Binary variable d(i,j) 'decision direct';
Binary variable dstar(i,j) 'decision routing';
Binary variable p(i,j) 'd(i,i)*dstar(i,j)';
Binary variable q(i,j) 'd(i,j)*p(i,j)';
Binary variable x(i,j) 'd(j,j)*dstar(i,j)';
Binary variable y(i,j) 'd(i,j)*x(i,j)';
Binary variable f(i,j) 'd(i,i)*d(j,j)';
Binary variable g(i,j) 'f(i,j)*dstar(i,j)';
Integer variable h(i) 'd(i,i)*u(i)';
Integer variable k(i,j) 'd(i,i)*u(j)';
Integer variable m(i,j) 'f(i,j)*u(i)';
Integer variable u(i) 'ordering of tours';
Equation
e1
e2(i,j)
e3
e4(j)
e5(i,j)
e6(i,j)
e7(i)
e8(j)
e9(i)
e10(i,j)
e11(i,j)
e12(i,j)
e13(i,j)
e14(i,j)
e15(i,j)
e16(i,j)
e17(i,j)
e18(i,j)
e19(i,j)
e20(i,j)
e21(i,j)
e22(i,j)
e23(i,j)
e24(i,j)
e25(i,j)
e26(i,j)
e27(i,j)
e28(i)
e29(i)
e30(i)
e31(i,j)
e32(i,j)
e33(i,j)
e34(i,j)
e35(i,j)
e36(i,j)
e37(i,j)
e38(i,j)
e39(i)
e40(i)
e41(i)
e42(i)
e43(i,j)
e44(i,j)
e45(i,j)
e46(i,j)
e47(i,j)
e48(i,j)
e49(i,j)
e50(i,j)
e51(i,j);
e1 .. z =e= sum((i,j),c(i,j))+sum((i,j),cstar(i,j));
e2(i,j) .. c(i,j) =e= A(i,j)*d(i,j);
e3 .. sum((i),d(i,i)) =e= 2;
e4(j) .. sum((i),d(i,j)) =e= 1;
e5(i,j) .. d(i,j)-d(i,i) =l= 0;
e6(i,j) .. cstar(i,j) =e= A(i,j)*dstar(i,j);
e7(i) .. dstar(i,i) =e= 0;
e8(j) .. sum((i),dstar(i,j)) =e= 1;
e9(i) .. sum((j),dstar(i,j)) =e= 1;
e10(i,j) .. p(i,j) =l= d(i,i);
e11(i,j) .. p(i,j) =l= dstar(i,j);
e12(i,j) .. p(i,j) =g= d(i,i)+dstar(i,j)-1;
e13(i,j) .. p(i,j) =g= 0;
e14(i,j) .. q(i,j) =l= d(i,j);
e15(i,j) .. q(i,j) =l= p(i,j);
e16(i,j) .. q(i,j) =g= d(i,j)+p(i,j)-1;
e17(i,j) .. q(i,j) =g= 0;
e18(i,j) .. p(i,j)-q(i,j) =e= 0;
e19(i,j) .. x(i,j) =l= d(j,j);
e20(i,j) .. x(i,j) =l= dstar(i,j);
e21(i,j) .. x(i,j) =g= d(j,j)+dstar(i,j)-1;
e22(i,j) .. x(i,j) =g= 0;
e23(i,j) .. y(i,j) =l= d(i,j);
e24(i,j) .. y(i,j) =l= x(i,j);
e25(i,j) .. y(i,j) =g= d(i,j)+x(i,j)-1;
e26(i,j) .. y(i,j) =g= 0;
e27(i,j) .. x(i,j)-y(i,j) =e= 0;
e28(i) .. u(i) =l= 20;
e29(i) .. 1000*(1-d(i,i)) =g= u(i)-1;
e30(i) .. 2-d(i,i) =l= u(i);
e31(i,j) .. f(i,j) =l= d(i,i);
e32(i,j) .. f(i,j) =l= dstar(j,j);
e33(i,j) .. f(i,j) =g= d(i,i)+dstar(j,j)-1;
e34(i,j) .. f(i,j) =g= 0;
e35(i,j) .. g(i,j) =l= f(i,j);
e36(i,j) .. g(i,j) =l= dstar(i,j);
e37(i,j) .. g(i,j) =g= f(i,j)+dtar(i,j)-1;
e38(i,j) .. g(i,j) =g= 0;
e39(i) .. 0 =l= h(i);
e40(i) .. h(i) =l= 1000*d(i,i);
e41(i) .. u(i)-1000*(1-d(i,i)) =l= h(i);
e42(i) .. h(i) =l= u(i);
e43(i,j) .. 0 =l= k(i,j);
e44(i,j) .. k(i,j) =l= 1000*d(i,i);
e45(i,j) .. u(j)-1000*(1-d(i,i)) =l= k(i,j);
e46(i,j) .. k(i,j) =l= u(j);
e47(i,j) .. 0 =l= m(i,j);
e48(i,j) .. m(i,j) =l= 1000*f(i,j);
e49(i,j) .. u(i)-1000*(1-f(i,j)) =l= m(i,j);
e50(i,j) .. m(i,j) =l= u(i);
e51(i,j) .. u(i)-u(j)+1-h(i)+k(i,j)-d(i,i)-k(j,i)+h(j)-d(j,j)-m(i,j)+m(j,i)-f(i,j) =l= 19*(1-d(i,i)-d(j,j)-f(i,j)-dstar(i,j)+p(i,j)+x(i,j)+g(i,j));
Model transport / all /;
solve transport using mip minimizing z;
display d.l, dstar.l;
The problem is, that you declared d (and other symbols) with domain (i,j) but try to access it as (i,i). Therefore, you get a domain violation since you declared i and j as different sets. Is that really wanted? Or are they really the same (i.e., is each origin also a destination)? Looking at table A that seems to be the case. So, instead of declaring j as a new set, you should define it as Alias to j. The start of your model would look like this then:
Set
i 'Origin' / 1*20 /;
Alias(i,j);
The rest stays the same.
I have a following problem:
There exists an entity called Branch.
A branch may belong to another branch or may be a standalone branch.
A parent branch may belong to another branch or may be the highest level branch.
There may be a UP TO 4-5 levels of hierarchy.
There are no loop hierarchies (that we know of as of right now).
I am wanting to somehow export the data from SQL and visualize into some sort of tree looking diagram. Any ideas are highly appreciated.
Here is a snapshot of my data model. Note that when DivisonParentBranch = RegionParentBranch = Branch, this implies that branch is standalone.
DivisionParentBranch RegionParentBranch Branch
150 401 401
150 401 402
150 401 403
150 401 404
273 248 248
273 248 277
273 248 278
273 273 273
273 273 286
273 273 408
273 273 809
356 356 356
356 356 358
356 356 363
356 356 405
356 356 773
356 357 357
356 361 361
356 361 364
739 511 511
739 511 513
739 511 514
739 511 515
739 511 517
739 511 519
739 511 520
739 511 779
UPDATE:
Expected Result is to visualize these branch hierarchies. Something along the lines of the below image. We have around 500+ branches so need to automate this somehow.
This isn't pretty and I am sure someone do better using the GROUP BY ROLLUP function but starting with the output of this you could loop through the results set and build a display based on the hierarchy from the select below. Level 1 would be the topmost part of the tree, level 2 would link to level 1 and be the second row, etc.
Also, as mentioned in the comments please don't post 'data' as screen prints.
SELECT div_branch, null as reg_branch, null as branch, '1' as level
FROM #bracnhes
GROUP BY div_branch
union all
SELECT div_branch, reg_branch, null as branch, '2' as level
FROM #bracnhes
GROUP BY div_branch, reg_branch
union all
SELECT div_branch, reg_branch, branch, '3' as level
FROM #bracnhes
GROUP BY div_branch, reg_branch, branch
My output, at least the little bit I bothered to test with looks like this
div_branch reg_branch branch level
150 NULL NULL 1
273 NULL NULL 1
356 NULL NULL 1
150 150 NULL 2
150 401 NULL 2
273 248 NULL 2
273 273 NULL 2
356 356 NULL 2
356 357 NULL 2
356 361 NULL 2
150 150 150 3
150 150 151 3
150 150 153 3
150 150 154 3
150 150 961 3