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)
Pandas TypeError: an integer is required (got type Timestamp) - Troubleshooting and Solution

原文地址: https://www.cveoy.top/t/topic/nzti 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录