如何让 pandas 在输出中显示大型数据集?

问题描述 投票:0回答:1

我正在处理一个非常大的Excel数据集,超过10万行,它包含小时和日期等数据,但它们没有分割(20231201而不是2023/12/01或1130而不是11:30),我设法编写了一个代码来分割它们,以便将它们复制并粘贴回 Excel 上,但是它并没有在输出中提供整个数据集,前 30k 行总是丢失...有没有办法设置输出电平无限大?

#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))
python pandas statistics
1个回答
0
投票

不,不幸的是,所有 IDE 都有显示数据集的限制。 但是,您可以逐行打印,直到到达数据框的末尾。

© www.soinside.com 2019 - 2024. All rights reserved.