Changing DataFrame values using bracket or dot notation
Many of the methods we've discussed can be used to change the values in a DataFrame, as well as select slices or ranges. In the following screenshot, we can see the GDP data that we have been working with for 2015:
Now, suppose that as part of the economic analysis, we want to increase all the GDP values by 5,000. We can do this by selecting the GDP
column using bracket notation on the left, and then doing the same and adding 5,000 on the right:
GDP_2015['GDP'] = GDP_2015['GDP'] + 5000
GDP_2015
This will produce the following output:
Here, we can see the expected result – that is, all our GDP
figures have been increased by 5,000. Thus, using bracket notation, we can choose where new data goes into...