Closed Pranav-Gairola closed 4 years ago
HI @Pranav-Gairola looks like your GTFS feed might be missing a service id. Can you share the GTFS zip file you are using? This is the one you are trying to get a representative feed of:
F:\PhD\GTFS\GTFS_trial.zip
As you can see here in the GTFS specifications, the service_id
is a required column. Without it, a GTFS feed is missing important information that allows a consumer to understand which schedules are associated with which trips, routes, etc.
Hi, thanks for responding Kuan. GTFS feed I'm using can be accessed from the link below. https://drive.google.com/open?id=1nJVaQP-O5urYDo6u0DBqh6eut3rZhznY
Hey! Can anyone help me out over this?
Hi @Pranav-Gairola I would recommend reviewing the README for how to load in a GTFS zip file. There is no need to pickle your file to just load and review a GTFS feed.
Here is the script I ran:
import peartree as pt
print(pt.__version__) # 0.6.3
path = "gh_issue_gtfs.zip"
# Automatically identify the busiest day and
# read that in as a Partidge feed
feed = pt.get_representative_feed(path)
# Set a target service time frame to model
start = 7*60*60 # 7:00 AM
end = 10*60*60 # 10:00 AM
# Convert feed into directed network multigraph
G = pt.load_feed_as_graph(feed, start, end)
This loaded in the file as the object G
.
In my Jupyter notebook, I was then able to generate a plot of the network with the following line:
%matplotlib inline
pt.generate_plot(G)
The rendered graph looks like this:
Hi @kuanb , Thanks for responding. I tried to follow your code in jupyter notebook and i got different error this time.
import peartree as pt path = "F:/PhD/GTFS/GTFS.zip" feed = pt.get_representative_feed(path) start = 56060 # 5:00 AM end = 126060 # 12:00 AM G = pt.load_feed_as_graph(feed, start, end) %matplotlib inline pt.plot.generate_plot(G)
AttributeError Traceback (most recent call last)
@kuanb , If I run the exact same code using pycharm interpreter, i am getting different attribute error than the last time. If there is no issue with the GTFS feed as you were able to plot it, what is the issue here?
Traceback (most recent call last):
File "F:/PhD/Python/Directed_multigraph.py", line 7, in
Your second nonzero error is captured in this issue. I think you may have an old version of pandas installed or an older version of peartree. I would recommend re-installing peartree to make sure you have the correct version of peartree and pandas.
Note how I printed the version of peartree I was using. You can do the same to make sure you are using the latest verson:
import peartree as pt
print(pt.__version__) # 0.6.3
Thanks for this. My second non zero error is removed once i uninstalled and then re-installed pandas 1.0.5 and peartree 0.6.3 both. Although, this time i have encountered different error.
AttributeError Traceback (most recent call last)
Now your issue looks like it is with your install of matplotlib
, not anything related to peartree
. It looks like you have a conda install of matplotlib
. I'd recommend going to forums there and seeing how people resolved the issue you are experiencing.
Ok, i 'll check there. Thank you so much for your help throughout on this.
Hi, Kuan. I got the following error in the notebook.
TypeError Traceback (most recent call last)
' syntax is deprecated. ':' is the preferred initialization method. When making the change, be mindful of axis order changes: https://pyproj4.github.io/pyproj/stable/gotchas.html#axis-order-changes-in-proj-6
return _prepare_from_string(" ".join(pjargs))
Hello everyone, I have been trying to implement an already existing code to plot GTFS feed but getting attribute error somewhere in pandas module getting called inside from peartree module. I would be thankful for any help. Python --version -3.8 OS -- Windows 10 P.S. I have updated required modules still the problem persists.
Script:-
try: import peartree as pt except: pass import os import pickle PKL_PATH = 'graph.pkl'
Creating the graph takes a gazillion time so I pickle it
if not os.path.exists(PKL_PATH):
Automatically identify the busiest day and
else: with open(PKL_PATH, 'rb') as pkl_file: G = pickle.load(pkl_file)
Traceback (most recent call last): File "F:/PhD/Python/Directed_multigraph.py", line 31, in
feed = pt.get_representative_feed("F:\PhD\GTFS\GTFS_trial.zip")
File "C:\Anaconda3\envs\Python\lib\site-packages\peartree\paths.py", line 95, in get_representative_feed
service_ids_by_date = ptg.read_service_ids_by_date(file_loc)
File "C:\Anaconda3\envs\Python\lib\site-packages\partridge\readers.py", line 72, in read_service_ids_by_date
return _service_ids_by_date(feed)
File "C:\Anaconda3\envs\Python\lib\site-packages\partridge\readers.py", line 156, in _service_ids_by_date
service_ids = set(feed.trips.service_id)
File "C:\Anaconda3\envs\Python\lib\site-packages\pandas\core\generic.py", line 5274, in getattr
return object.getattribute(self, name)
AttributeError: 'DataFrame' object has no attribute 'service_id'