Please I need help my csv
file downloaded from this site
https://catalog.data.gov/dataset/state-drug-utilization-data-2016 and I am working by pandas to analyses it I need to reach to column in the file and I do this
import pandas as pd
url = "E:\dataset\state_dataset\Drug_Utilization_2017_-_California.csv"
df=pd.read_csv(url)
df.dropna(inplace=True)
df.shape
df.columns()
and the error was
TypeError: 'Index' object is not callable
when I try to Know the type of one column in the file I do this
type(df.'state'[0])
and "state" is an column in my csv file and the error was
SyntaxError: invalid syntax
Sorry to send two types of error but I am really try so many times and I fail.
It may be helpful to follow a tutorial on how to use pandas:
df.columns
is not callable, you cannot df.columns()
it, hence TypeError: 'Index' object is not callable
.
type(df.'state'[0])
is not how you get a column in pandas, they are not attributes of the dataframe and you can't use strings as attribute names, hence the SyntaxError:
df['state'][0]
is how you would get the first item in the 'state' column.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With