Dataframe was extracted from a CSV file, and is converted into a string through the following code:
import pandas as pd
import re
input_csv_file = "./CSV/Officers_and_Shareholders.csv"
df = pd.read_csv(input_csv_file, skiprows=10, on_bad_lines='skip', names= ['Nama', 'Jabatan', 'Alamat', 'Klasifikasi Saham', 'Jumlah Lembar Saham', 'Total'])
df.fillna('', inplace=True)
# df.drop([0, 3], inplace=True)
df.columns = ['Nama', 'Jabatan', 'Alamat', 'Klasifikasi Saham', 'Jumlah Lembar Saham', 'Total']
pattern_shareholding_numbers = re.compile(r'[\d.]*\d+')
shareholding_percentage_list = df["Jumlah Lembar Saham"].astype(str)
shareholding_percentage_thousand_separator_removed = df["Jumlah Lembar Saham"].str.replace('.', '')
shareholding_percentage_string = ' '.join(shareholding_percentage_thousand_separator_removed)
matches = pattern_shareholding_numbers.findall(shareholding_percentage_string)
print(matches)
So through the code on the above, an output of the following can be extracted from the CSV file, which looks like the following:
['3200000', '2900000', '2900000', '1000000']
The numbers shown on the above is a data extracted under the "Jumlah Lembar Saham" column, and the numbers are extracted from different rows within the dataframe. I was wondering if there is a method to add all of the numbers on the above, resulting in one number such as:
['10000000']