I would like more info. on the answer to the following question:
- df[‘Name’] and 2. df.loc[:, ‘Name’], where:
df = pd.DataFrame(['aa', 'bb', 'xx', 'uu'], [21, 16, 50, 33], columns = ['Name', 'Age'])
Choose the correct option:
- 1 is the view of original dataframe and 2 is a copy of original
dataframe - 2 is the view of original dataframe and 1 is a copy of original dataframe
- Both are copies of original dataframe
- Both are views of original dataframe
I found more than one answer online but not sure. I think the answer is number 2 but when i tried x = df['name'] then x[0] = 'cc' then print(df) I saw that the change appeared in the original dataframe. So how the changed appeared in the original dataframe although I also got this warining: A value is trying to be set on a copy of a slice from a DataFrame
I just want to know more about the difference between the two and weather one is really a copy of the original dataframe or not. Thank you.