|
342 | 342 | "background_color = '#0a0a23'\n", |
343 | 343 | "font_color = '#ffffff'\n", |
344 | 344 | "\n", |
345 | | - "string_template = writer.book.add_format(\n", |
| 345 | + "string_format = writer.book.add_format(\n", |
346 | 346 | " {\n", |
347 | 347 | " 'font_color': font_color,\n", |
348 | 348 | " 'bg_color': background_color,\n", |
349 | 349 | " 'border': 1\n", |
350 | 350 | " }\n", |
351 | 351 | " )\n", |
352 | 352 | "\n", |
353 | | - "dollar_template = writer.book.add_format(\n", |
| 353 | + "dollar_format = writer.book.add_format(\n", |
354 | 354 | " {\n", |
355 | 355 | " 'num_format':'$0.00',\n", |
356 | 356 | " 'font_color': font_color,\n", |
|
359 | 359 | " }\n", |
360 | 360 | " )\n", |
361 | 361 | "\n", |
362 | | - "integer_template = writer.book.add_format(\n", |
| 362 | + "integer_format = writer.book.add_format(\n", |
363 | 363 | " {\n", |
364 | 364 | " 'num_format':'0',\n", |
365 | 365 | " 'font_color': font_color,\n", |
|
382 | 382 | "```python\n", |
383 | 383 | "writer.sheets['Recommended Trades'].set_column('B:B', #This tells the method to apply the format to column B\n", |
384 | 384 | " 18, #This tells the method to apply a column width of 18 pixels\n", |
385 | | - " string_template #This applies the format 'string_template' to the column\n", |
| 385 | + " string_format #This applies the format 'string_format' to the column\n", |
386 | 386 | " )\n", |
387 | 387 | "```" |
388 | 388 | ] |
|
393 | 393 | "metadata": {}, |
394 | 394 | "outputs": [], |
395 | 395 | "source": [ |
396 | | - "# writer.sheets['Recommended Trades'].write('A1', 'Ticker', string_template)\n", |
397 | | - "# writer.sheets['Recommended Trades'].write('B1', 'Price', string_template)\n", |
398 | | - "# writer.sheets['Recommended Trades'].write('C1', 'Market Capitalization', string_template)\n", |
399 | | - "# writer.sheets['Recommended Trades'].write('D1', 'Number Of Shares to Buy', string_template)\n", |
400 | | - "# writer.sheets['Recommended Trades'].set_column('A:A', 20, string_template)\n", |
401 | | - "# writer.sheets['Recommended Trades'].set_column('B:B', 20, dollar_template)\n", |
402 | | - "# writer.sheets['Recommended Trades'].set_column('C:C', 20, dollar_template)\n", |
403 | | - "# writer.sheets['Recommended Trades'].set_column('D:D', 20, integer_template)\n" |
| 396 | + "# writer.sheets['Recommended Trades'].write('A1', 'Ticker', string_format)\n", |
| 397 | + "# writer.sheets['Recommended Trades'].write('B1', 'Price', string_format)\n", |
| 398 | + "# writer.sheets['Recommended Trades'].write('C1', 'Market Capitalization', string_format)\n", |
| 399 | + "# writer.sheets['Recommended Trades'].write('D1', 'Number Of Shares to Buy', string_format)\n", |
| 400 | + "# writer.sheets['Recommended Trades'].set_column('A:A', 20, string_format)\n", |
| 401 | + "# writer.sheets['Recommended Trades'].set_column('B:B', 20, dollar_format)\n", |
| 402 | + "# writer.sheets['Recommended Trades'].set_column('C:C', 20, dollar_format)\n", |
| 403 | + "# writer.sheets['Recommended Trades'].set_column('D:D', 20, integer_format)\n" |
404 | 404 | ] |
405 | 405 | }, |
406 | 406 | { |
|
419 | 419 | "outputs": [], |
420 | 420 | "source": [ |
421 | 421 | "column_formats = { \n", |
422 | | - " 'A': ['Ticker', string_template],\n", |
423 | | - " 'B': ['Price', dollar_template],\n", |
424 | | - " 'C': ['Market Capitalization', dollar_template],\n", |
425 | | - " 'D': ['Number of Shares to Buy', integer_template]\n", |
| 422 | + " 'A': ['Ticker', string_format],\n", |
| 423 | + " 'B': ['Price', dollar_format],\n", |
| 424 | + " 'C': ['Market Capitalization', dollar_format],\n", |
| 425 | + " 'D': ['Number of Shares to Buy', integer_format]\n", |
426 | 426 | " }\n", |
427 | 427 | "\n", |
428 | 428 | "for column in column_formats.keys():\n", |
429 | 429 | " writer.sheets['Recommended Trades'].set_column(f'{column}:{column}', 20, column_formats[column][1])\n", |
430 | | - " writer.sheets['Recommended Trades'].write(f'{column}1', column_formats[column][0], string_template)" |
| 430 | + " writer.sheets['Recommended Trades'].write(f'{column}1', column_formats[column][0], string_format)" |
431 | 431 | ] |
432 | 432 | }, |
433 | 433 | { |
|
465 | 465 | "name": "python", |
466 | 466 | "nbconvert_exporter": "python", |
467 | 467 | "pygments_lexer": "ipython3", |
468 | | - "version": "3.8.2" |
| 468 | + "version": "3.8.5" |
469 | 469 | } |
470 | 470 | }, |
471 | 471 | "nbformat": 4, |
|
0 commit comments