(Jan-04-2019, 08:58 PM)carstenlp Wrote: Thx for input. Im using pycharm. From what i understand VS code is just another editor
Sure,but in my option the best multilanguage editor out there and take how Python work in editor more seriously than others.
(Jan-04-2019, 08:58 PM)carstenlp Wrote: Im still in doubt how i add columns and how to sum up 2 columns to the new one.
Like this.
import pandas as pd
pd.set_option('display.max_columns', None)
d = {
'date': [20110911, 20110918],
'day': ['Sunday', 'Sunday'],
'line': [2.0, 6.0],
'o:points': [12, 30],
'o:team': ['Falcons', 'Saints'],
'points': [30, 13],
'season': [2011, 2011],
'site': ['home', 'away'],
'team': ['Bears', 'Bears'],
'total': [40.5, 47.0],
'week': [1, 2]
}
df = pd.DataFrame.from_dict(d)
df['total_points'] = df['o:points'] + df['points'] # assigned to a new column
print(df)
Will add a new column.
Output:
week total_points
0 1 42
1 2 43
Sum it all up:
df['total_points'].sum()
85