brendan.mcdevitt.tech/_programming/2021-01-30-python-pandas-transform-csv.markdown
Brendan McDevitt e6c312a1ec big update
2022-02-25 01:56:24 -05:00

26 lines
771 B
Markdown

---
layout: programming
title: "python pandas: transform csv - add a new column"
date: 2021-01-30
categories: programming
---
# Problem:
I needed to group severity of CVEs for a project I am working on into low,
medium, and high ranges. We have a risk score value between 0-100 that we can use to
categorize each CVE into a range.
<br>
# Solution:
We use the pandas library because it has some methods already written that allow
us to read a csv file and apply our severity function to the data on each row
in our csv file.
We can use the apply() function to do this with a lambda. We can define a new
column this way and it will write out the newly computed data to its own column
at the end of our file.
<br>
{% include apple_advisories_cve_risk_scores.html %}