0

I am trying to extract the Start Station from a csv file, example data below.

Start Time,End Time,Trip Duration,Start Station,End Station,User Type,Gender,Birth Year

1423854,2017-06-23 15:09:32,2017-06-23 15:14:53,321,Wood St & Hubbard St,Damen Ave & Chicago Ave,Subscriber,Male,1992.0

The problem I am having is when I try to extract the data I receive the following error message:

AttributeError: 'Series' object has no attribute 'start'

def load_data(city, month, day):

# load data file into a dataframe
df = pd.read_csv(CITY_DATA[city])

I believe my problem stems from converting the Start Station, but can't seem to figure why.

# convert the Start Station column to dataframe
df['Start Station'] = pd.DataFrame(df['Start Station'])

# extract street names from Start Station and End Station to create new columns
df['start'] = df['Start Station'].start

def station_stats(df):
"""Displays statistics on the most popular stations and trip."""

# TO DO: display most commonly used start station
popular_start_station = df['start']
print(popular_start_station)
Max von Hippel
  • 2,856
  • 3
  • 29
  • 46

1 Answers1

0

Your code is confusing. Just try this:

df = pd.read_csv(CITY_DATA, index = True) # load data file into a one df
start_data_series = df[['Start Station']] # create series with column of interest

You can add more columns to the second line according to your liking. For further reading, refer to this post.

sudonym
  • 3,788
  • 4
  • 36
  • 61