Mar-25-2019, 08:51 AM
As it could be seen from the context (df - variable), you are using Pandas.
So, you can create Pandas dataframe from string:
So, you can create Pandas dataframe from string:
from io import StringIO import pandas as pd # text variable defined here data = pd.read_table(StringIO(text), sep='\s', header=None)Further, you can get access to the first column, e.g.
data.iloc[:, 0]
, apply mapping to it or do anything you want.data.iloc[2:, -1].sum()
returns sum you are trying to find.