I have been having issues with printing all columns in a csv file. The data within is set out strange in my opinion however it is not relevant.
I have been using pandas to see trends within a data csv file. I was trying to print out the data as well as showing it graphically with pandas. When I try to print the filtered variable with all the data, because the data spans across many columns with the dates at the top ( I will attach a photo of the code in terminal and the data file so it is not too confusing) it does not seem to want to print all the data.
I have tried different methods such as changing it to the list() function, trying to convert it into .to_string or .to_html, however that didn't work. In the screenshot attached it is after doing .to_string however it just outputs this at the start "<bound method DataFrame.to_html of" and then prints some columns dates however not the data under them
def region_check(region, startdate, enddate, house_type): # region, startdate, enddate
df1 = df.loc[:, startdate:enddate]
df2 = df.loc[:, 'Region Code':'Rooms']
prop_filter = df["Property_Type"] == house_type
result = pd.concat([df2, df1], axis=1, join='inner').where(df2["Region"] == region).where(prop_filter)
result = pd.DataFrame(result)
result.dropna(inplace=True)
print(result) # This is where it prints the data as text. At the end of result is
where I was adding .to_string/html
ave = df1.mean()
ave.plot()
plt.show()
return result
Screenshot of problem with .to_html
Although setting the pandas option to view all columns is one option, the printed table isn't pretty. Hence, I'll recommend the use of the tabulate package.
Method 1: Print all columns after enabling the pandas option:
Method 2: Pretty print table via using the following: