How to make pandas show large datasets in output?

48 views Asked by At

I am working on a very large excel dataset, with more than 100 thousand rows, it contains data such as hours and dates, but they are not split (20231201 instead of 2023/12/01 or 1130 instead of 11:30),i managed to write a code that splits them in order to copy and paste them back on excel, however it doesn't give me the whole dataset in output, the first 30k rows are always missing... is there a way to set the output level to infinite?

#this is the code for hours
import pandas as pd

df = pd.read_excel('/Volumes/PortableSSD/Università - Lavori/Progetto statistica/Definitivo 1223.xlsx')

df['Scheduled departure'] = df['Scheduled departure'].astype(str)

df['formatted_hour'] = df['Scheduled departure'].apply(lambda x: '{:0>4}'.format(x))

df['formatted_hour'] = df['formatted_hour'].apply(lambda x: f"{x[:2]}:{x[2:]}")

# Display the formatted time
print(df['formatted_hour'].to_string(index=True))
#this is the code for dates
import pandas as pd

df = pd.read_excel('/Volumes/PortableSSD/Università - Lavori/Progetto statistica/Definitivo 1223.xlsx')

df['Date'] = df['Date'].astype(str)
df['year'] = df['Date'].str[:4]
df['month'] = df['Date'].str[4:6]
df['day'] = df['Date'].str[6:]

df['formatted_date'] = df['Date'].str[6:] + '/' + df['Date'].str[4:6] + '/' + df['Date'].str[:4]

# Display the formatted date
print(df['formatted_date'].to_string(index=False))
2

There are 2 answers

0
DataSciRookie On

No, unfortunately, all IDE have limitations to display datasets. However, you can print row by row until you reach the end of your dataframe.

1
Valiant Tyro On

Why don't you try to format the columns as per your requirement and overwrite your file with formatted columns?

df.to_excel(<path to file>, index = False)