I'm new to python so please bear with me!
I'm trying to create a dataframe using pandas from a .csv file that has rows with different numbers of columns and put them into a dictionary. The picture I added is an example - some .csv files start with a row that has 5 columns, but later on we have 7 columns.
This is the code I have right now:
my_dataframes = {}
for filename in sorted_files:
temp_frame = pd.read_csv(filename, header=None, usecols=range(0, 6))
# temp_frame['Timestamp'] = temp_frame[0] + ' ' + temp_frame[1]
# temp_frame.rename(columns={2: 'Action'}, inplace=True)
# del temp_frame[0]
# del temp_frame[1]
my_dataframes[filename] = temp_frame
I commented some bits out, I'm just trying to merge columns and rename, yada yada. I tried using usecols to have it read 7 columns even if the first row had less than 7, but that didn't work. What I'm looking for is a dataframe that has 7 columns (all the rows have 5-7 columns), and whatever is null, is just null.
Thanks in advance! Appreciate any help :)