Question: Given a pandas dataframe, df, as follows: open high low close volume 2021-11-15 1017.63 1031.9800 978.60 1013.39 34775649 2021-11-16 1003.31 1057.1999 1002.18 1054.73 26542359 2021-11-17
Given a pandas dataframe, df, as follows:
open | | high | low | close | volume | |
2021-11-15 | 1017.63 | | 1031.9800 | 978.60 | 1013.39 | 34775649 |
2021-11-16 | 1003.31 | | 1057.1999 | 1002.18 | 1054.73 | 26542359 |
2021-11-17 | 1063.51 | | 1119.6400 | 1055.50 | 1089.01 | 31445365 |
2021-11-18 | 1106.55 | | 1112.0000 | 1075.02 | 1096.38 | 20898930 |
2021-11-19 | 1098.87 | | 1138.7199 | 1092.70 | 1137.06 | 21642258 |
How would you keep only two columns from the dataframe?
| a. | df=df['date', 'close'] | |
| b. | df=df[['date', 'close']] | |
| c. | index.set_names(['date', 'open']) | |
| d. | Index(['date', 'open']) |
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
