当我想将信息写入csv文件时遇到问题
我的整个代码是:
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
lokasiData = "drive/My Drive/Tubes Manli/used_cars.csv"
ds = pd.read_csv(lokasiData) #ds = data set
ds.head
ds.isnull().sum()
#2 Drop kolom county
ds.drop(ds.columns[ds.columns.str.contains('county',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom size
ds.drop(ds.columns[ds.columns.str.contains('size',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom url
ds.drop(ds.columns[ds.columns.str.contains('url',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom region_url
ds.drop(ds.columns[ds.columns.str.contains('region_url',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom image_url
ds.drop(ds.columns[ds.columns.str.contains('image_url',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom description
ds.drop(ds.columns[ds.columns.str.contains('description',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom vin
ds.drop(ds.columns[ds.columns.str.contains('vin',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom state
ds.drop(ds.columns[ds.columns.str.contains('state',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom lat
ds.drop(ds.columns[ds.columns.str.contains('lat',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom long
ds.drop(ds.columns[ds.columns.str.contains('long',case = False)],axis = 1, inplace = True)
ds.to_csv(lokasiData)
# Drop kolom unnamed
ds.drop(ds.filter(regex="Unnamed"),axis=1, inplace=True)
ds.to_csv(lokasiData, index=False, sep=',')
this is the picture of my colab explorer
请帮我,这是一个项目,以换取我的期末考试。谢谢
答案 0 :(得分:0)
您忘记调用安装Google驱动器所需的模块。
如果是第一次使用,则需要进行身份验证。
验证并安装驱动器后,使用以下命令,
from google.colab import drive
drive.mount(‘/content/drive/My Drive/Tubes Manli/used_cars.csv’)
这应该可以解决该错误。