---------------------------------------------------------------------------TypeError Traceback most recent call lastipython-input-102-5be45ded9b1b in module 17 df T
This error occurs because the lambda function in line 19 expects an integer as input, but it is receiving a pandas Timestamp object. The conversion to Timestamp in line 18 is already sufficient, so the lambda function can be removed. The corrected code would be:
import pandas as pd
df = pd.read_csv('data.csv')
df[' Timestamp'] = pd.to_datetime(df[' Timestamp'], unit='s')
df.set_index(' Timestamp', inplace=True)
原文地址: https://www.cveoy.top/t/topic/cK7L 著作权归作者所有。请勿转载和采集!