|
553 | 553 | "cell_type": "markdown", |
554 | 554 | "metadata": {}, |
555 | 555 | "source": [ |
556 | | - "## Read measures of an Excel file\n", |
| 556 | + "## Read/write measure sets to/from Excel files\n", |
557 | 557 | "\n", |
558 | | - "Measures defined in an excel file following the template provided in sheet `measures` of `climada_python/data/system/entity_template.xlsx` can be ingested directly using the method `from_excel()`." |
| 558 | + "Measures defined in an excel file following the template provided in sheet `measures` of `climada_python/data/system/entity_template.xlsx` can be ingested directly using the method `from_excel()`. Measure sets can be written to file with the method `write_excel()`." |
559 | 559 | ] |
560 | 560 | }, |
561 | 561 | { |
|
585 | 585 | "\n", |
586 | 586 | "# Fill DataFrame from Excel file\n", |
587 | 587 | "file_name = ENT_TEMPLATE_XLS # provide absolute path of the excel file\n", |
588 | | - "meas_set = MeasureSet.from_excel(file_name)\n", |
589 | | - "meas_set" |
590 | | - ] |
591 | | - }, |
592 | | - { |
593 | | - "cell_type": "markdown", |
594 | | - "metadata": {}, |
595 | | - "source": [ |
596 | | - "## Write measures\n", |
597 | | - "\n", |
598 | | - "Measures can be writen in Excel format using `write_excel()` method." |
599 | | - ] |
600 | | - }, |
601 | | - { |
602 | | - "cell_type": "code", |
603 | | - "execution_count": 8, |
604 | | - "metadata": { |
605 | | - "ExecuteTime": { |
606 | | - "end_time": "2021-03-05T11:44:20.460278Z", |
607 | | - "start_time": "2021-03-05T11:44:16.581Z" |
608 | | - } |
609 | | - }, |
610 | | - "outputs": [], |
611 | | - "source": [ |
612 | | - "from climada.entity.measures import MeasureSet\n", |
613 | | - "from climada.util import ENT_TEMPLATE_XLS\n", |
614 | | - "\n", |
615 | | - "# Fill DataFrame from Excel file\n", |
616 | | - "file_name = ENT_TEMPLATE_XLS # provide absolute path of the excel file\n", |
617 | | - "meas_set = MeasureSet.from_excel(file_name)\n", |
618 | | - "\n", |
619 | | - "# write file\n", |
620 | | - "meas_set.write_excel(\"results/tutorial_meas_set.xlsx\")" |
621 | | - ] |
622 | | - }, |
623 | | - { |
624 | | - "cell_type": "markdown", |
625 | | - "id": "adb8d606", |
626 | | - "metadata": {}, |
627 | | - "source": [ |
628 | | - "Pickle can be used as well, but note that pickle has a [transient format](saving-with-pickle) and should be avoided when possible:" |
629 | | - ] |
630 | | - }, |
631 | | - { |
632 | | - "cell_type": "code", |
633 | | - "execution_count": 9, |
634 | | - "metadata": { |
635 | | - "ExecuteTime": { |
636 | | - "end_time": "2021-03-05T11:44:20.462069Z", |
637 | | - "start_time": "2021-03-05T11:44:16.599Z" |
638 | | - } |
639 | | - }, |
640 | | - "outputs": [], |
641 | | - "source": [ |
642 | | - "from climada.util.save import save\n", |
643 | | - "\n", |
644 | | - "# this generates a results folder in the current path and stores the output there\n", |
645 | | - "save(\"tutorial_meas_set.p\", meas_set)" |
| 588 | + "meas_set = MeasureSet.from_excel(file_name)" |
646 | 589 | ] |
647 | 590 | } |
648 | 591 | ], |
649 | 592 | "metadata": { |
650 | 593 | "hide_input": false, |
651 | 594 | "kernelspec": { |
652 | | - "display_name": "Python 3.8.12 ('climada_core')", |
| 595 | + "display_name": "Python 3 (ipykernel)", |
653 | 596 | "language": "python", |
654 | 597 | "name": "python3" |
655 | 598 | }, |
|
0 commit comments