i have bunch of csv files i have following code to merge them: import pandas as pd…
- User
i have bunch of csv files i have following code to merge them: import pandas as pd import os
Directory where all your CSV files are located
csv_directory = r"C:\Users\arisa\Desktop\day_spot"
List all CSV files in the given directory
csv_files = [file for file in os.listdir(csv_directory) if file.endswith('.csv')]
Placeholder for storing the data frames
data_frames = []
Loop over the list of csv files
for csv_file in csv_files: # Read the CSV file and append it to the list of data frames file_path = os.path.join(csv_directory, csv_file) df = pd.read_csv(file_path) data_frames.append(df)
Concatenate all data frames to create a single data frame
combined_df = pd.concat(data_frames, ignore_index=True)
Save the combined data frame to a new CSV file
combined_csv_path = r'C:\Users\arisa\Desktop\combined_day.csv' combined_df.to_csv(combined_csv_path, index=False)
print(f'Combined CSV created at: {combined_csv_path}')
i want to update the code so that in final file: i want to remove all the columns except the ones that: A.The columns which their names that contains: Open, High, Low, Close,macd,sma,wma,ema,rsi,cci,stoch,_short,_ichimoku,_dr B.The columns which their names that ends whith: volume_base, volume_crypto, tradecount C.The columns after y_High_1d(including y_High_1d itself)
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.