My Data:
My Code:
DTst = gc.open_by_url('https://xxsxx')
DTsc = DTst.worksheet('Sales1')
DTv = DTsc.get_all_values()
DTv = pd.DataFrame.from_records(DTv[1:], columns=DTv[0])
DTUser = DTv.loc[:, ['Items', 'Amount']]
DTUser.head()
Output:
The problem is, i want the output to be like in the 2nd image,but right now it called the data from both columns since the column have the same name.
CodePudding user response:
You could use iloc() function to get specific columns in range. https://www.geeksforgeeks.org/how-to-get-first-column-of-pandas-dataframe/
CodePudding user response:
DTv.iloc[:,0:2]
looks better approach in this case I think