Home > Mobile >  Showing both duplicates data?
Showing both duplicates data?

Time:10-13

My Data:

enter image description here

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:

enter image description here

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.

enter image description here

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

  • Related