首页 > 解决方案 > How to parse_dates for the Imported CSV File in google colab ?? the CSV file is imported from the Local drive

问题描述

In Google Colab I have imported the CSV file from local drive, using the below code :

from google.colab import files
uploaded = files.upload()

then to read the CSV file to parse_date I have the below code :

import pandas as pd
import io
df = pd.read_csv(io.StringIO(uploaded['Auto.csv'], parse_dates = ['Date'],date_parser=parse))
print(df)

it show's the error message as below :

TypeError: StringIO() takes at most 2 arguments (3 given)

But when importing file from github it works good for example shown below :

df = pd.read_csv('https://raw.githubusercontent.com/master/dataset/electricity_consumption.csv', parse_dates = ['Bill_Date'],date_parser=parse)    #this code works good from github

so I want to parse_dates for the csv file imported from the Local drive ??? Kindly help me on this???

Data set looks like this :

enter image description here

标签: pythonpandascsvparsinggoogle-colaboratory

解决方案


推荐阅读