Python Forum
pandas index not updating please help
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pandas index not updating please help
#1
I can't get rid of the old index, still shows the old index and the index title is on top of the old one. what might be the reason for it? Thanks :) the data source is: https://github.com/KeithGalli/Pandas-Dat...esAnalysis

i downloaded the data and i was watching from tutorial but in the video this problem didn't occur

import pandas as pd import os df = pd.read_csv('./Sales_Data/Sales_April_2019.csv') files = [file for file in os.listdir('./Sales_Data')] all_months_data = pd.DataFrame() for file in files: df = pd.read_csv('./Sales_Data/'+ file) all_months_data = pd.concat([all_months_data,df]) all_months_data.head() all_months_data.to_csv('all_data.csv', index=False) nan_df = all_data[all_data.isna().any(axis=1)] nan_df.head() all_data = all_data.dropna(how='all') all_data.head() all_data['Month']= all_data['Order Date'].str[0:2] all_data.Month=[int(x.strip('/')) if type(x)==str else x for x in all_data.Month] #In mine it showed the months as 4/ so thats why i had to do it all_data['Month'] = all_data['Month'].astype('int32') all_data.head() all_data = all_data[all_data['Order Date'].str[0:2] !='Or'] all_data = all_data.reset_index(drop=True) #for some reason the index jumps 0 to 2 even though the info is ordered just like the downloaded the data all_data.head() 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pandas pivot table: How to find count for each group in Index and Column JaneTan 0 5,622 Oct-23-2021, 04:35 AM
Last Post: JaneTan
  Pandas dataframe without index tgottsc1 3 79,784 Feb-01-2021, 05:29 PM
Last Post: snippsat
  Pandas default index remove nio74maz 2 2,979 Dec-27-2020, 02:41 PM
Last Post: nio74maz

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.