<jupyter_start><jupyter_text>Approach - 1 | Using DataFrames<jupyter_code>df = pd.DataFrame()

for i in os.listdir('Sales'):            # Going through each CSV File

  file_path = 'Sales/' + i               # Creating Path for each CSV file
  month = i.split('.')[0]                # Finding Month of CSV File

  df_ = pd.read_csv(file_path)           # Reading the CSV File

  month_column = df_.shape[0] * [month]  # Creating Month Column Data
  df_['Month'] = month_column            # Creating Month Column

  df = pd.concat([df,df_])               # Add Data in master DataFrmae
df.head()<jupyter_output><empty_output><jupyter_text>Approach - 2 | Using Arrays<jupyter_code>data = []

for i in os.listdir('Sales'):                                 # Going through each CSV file

  file_path = 'Sales/' + i                                    # Creating CSV File Name
  month = i.split('.')[0]                                     # Finding Month Name

  df_ = pd.read_csv(file_path).values                         # Loading CSV file in Numpy Array Format
  month_column = np.array(df_.shape[0] * [month])             # Creating Data Month Column
  month_column = np.reshape(month_column, (df_.shape[0],1))   # Reshaping Data Month to Concatenate        
  df_ = np.hstack([df_,month_column])                         # Adding Month Column in Array

  data.append(df_)                                            # Appending All Arrays into one List

df = np.vstack(data)                                          # Concatenating all Arrays
df = pd.DataFrame(df, columns = ['order_id','product','quantity','price','date','address','month'])

df.head()
df = df.dropna()
df.isnull().sum()
df.to_csv('sales.csv',index = False)
df<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup