I have a very large dataframe of string numbers, something like for example:
a,b,c
\"1\",\"2\",\"3\"
\"4\",\"5\",\"6\"
\"7\",\"8\",\"9\"
And I
In my opinion read_csv
convert columns to integers.
So use:
df = pd.read_csv(file)
df['d'] = df['a'] + df['c']
But if failed, then try convert to integer or floats:
df = pd.read_csv(file)
df['d'] = df['a'].astype(int) + df['c'].astype(int)
#floats
#df['d'] = df['a'].astype(float) + df['c'].astype(float)
If there are also some strings between numeric is possible convert problems values to NaN
s and sum:
df = pd.read_csv(file)
df['d'] = pd.to_numeric(df['a'], errors='coerce') + pd.to_numeric(df['c'], errors='coerce')