这是我在这里的第一篇帖子,所以请原谅我的帖子中的任何错误。你知道吗
这是我的密码。我试图过滤和打印这些数据,但是当脚本运行时,它会打印所有的列标题,这是我不想要的。有什么建议吗?你知道吗
import pandas as pd
data = pd.read_csv("/Users/andrewschaper/Desktop/EQR_Data/EQR_Transactions_1.csv", low_memory=False)
print("Total rows: {0}".format(len(data)))
print(list(data))
df = pd.DataFrame(data)
df.sort_values(by=['Filing_Quarter','product_name','time_zone','increment_name'],ascending=[True, True, True, True])
df.filter(items=['RECID', 'transaction_unique_id', 'ferc_tariff_reference', 'contract_service_agreement', 'transaction_unique_identifier', 'transaction_begin_date', 'transaction_end_date', 'trade_date', 'exchange_brokerage_service', 'point_of_delivery_specific_location', 'class_name', 'term_name', 'increment_peaking_name'])
print(df)
你应该把你的代码复制粘贴到这里,但我认为这样可以:
请记住,
df[items]
只打印过滤后的数据帧,不会删除其他列。如果这就是你想要的,那么filtered_df = df[items]
。你知道吗相关问题 更多 >
编程相关推荐