Data Science Chronicles: Miscellaneous Python tasks

Lado Ok
3 min readApr 3, 2024

--

I constructed an excel table using python from an empty cell in Jupyter Notebook.

Mood when I looked to commence the task.

An abstract addition but a worthy means of enhancing my Python proficiency. Despite gaining experience in constructing pipelines and evaluating errors with Scikit-learn, visualizing insights with Seaborn and Matplotlib through practice, I realized I hadn’t built an entire DataFrame from scratch, using the Pandas library. This presented the ideal opportunity for me to fill that gap in my skill set.

Side Task — By the way, keen to share this abstract from a HackerRank task I worked on. Function, determining leap years.

The moment I grasped the concepts: Function with embedded If Else statement determining a leap year or not.

Main task I got sent a page of writing containing details that needed to be illustrated on a spreadsheet. Powerpoint? Excel should be straightforward I thought but why not try with python. Consulted GPT where I was thrown a few ways of starting the process.

Figure I: Image with tabular transformation request.

The data variable is structured as nested lists within a dictionary. The key “CICMP PLATINUM” denotes the column header, with the associated lists representing the data within each cell of that column. The empty strings interspersed between the lists create visual gaps between rows, enhancing readability and organization in the data presentation.

Figure II: Lengthy code used to derive first column

New columns were added adjacent to the original ones, initially filled with empty strings. These new columns were accessed using keys like data[‘ ‘] and data[‘ . ‘]. No titles were assigned to these columns at this stage, as they were intended to be populated with row data later on, such as “Chapter Title” and “Cohort”.

Figure III: Forward Indexing used to identify and select the row within each new created column
Figure IV: Column 3 with another emptry string to identify.
Figure V: Process of assigning the DataFrame and saving it.
Figure VI: DataFrame displayed in Jupyter Notebook
Figure VII: Final table appearance.

Using excel configurations, I customised features in the table such as making certain text bold, adding colour to the existing set.

Bearing in mind the main task here was assembling the Table using python; understand the final form is in it’s minimal state aesthetically, it fulfils the intended purpose.

Overall fairly straightforward in nature but it provided valuable practice.

Please share feedback on all it’s aspects of the task.

--

--

No responses yet