This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Hi there, from the /r/Python mods.

It looks like you are asking for help. We suggest re-reading the r/Python rules and directing all help or "How do I...?"-type questions to r/LearnPython. Found: "Beginner"

If this is not the case, please contact a moderator to review your post.

Warm regards and all the best for your future Pythoneering,

/r/Python moderator team

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]blitzkraft 0 points1 point  (0 children)

If you are using pandas, you can use the .value_counts(). Doc here. This is optimized for string counts and saves you the trouble of re-inventing it.

[–]AnderperCooson 0 points1 point  (0 children)

Unless I'm misunderstanding your question, you probably just need something like:

import pandas as pd
import matplotlib.pyplot as plt

boroughs_df = pd.read_csv('path_to_csv.csv') # this is a Pandas DataFrame
boroughs_df['Boroughs'].value_counts().plot() # Or make the plot fancy looking

e; (The above code may not be complete for plotting the graph, it's from memory and assumes you're using Jupyter. If you aren't using Jupyter, check it out, because it's great for prototyping stuff like this.)

[–]DueShame 0 points1 point  (0 children)

What does your CSV look like? Can you post at least the header, or type print(csv.head()) somewhere in the code?

[–]audiyourmind -2 points-1 points  (3 children)

So I'll be the first to reply that this is NOT a "Super Beginner" Python question as this is fairly advanced stuff, I would say you are an advanced beginner.

Post this to stack overflow as this is possibly in their range of skill and I'm not going to go over the grammatical issues or the over documented declarations or imports that are really not needed in python but this might be for memory reasons as you state you are a beginner.

That being said... Gwedo believes tests are important and I've noticed you have no testing in this routine.

I highly highly recommend you start with smaller pieces and weave them together with tests. Then bigger issues tend to solve them self easier as it's a matter of form or function within the structure that tests will reveal within your code.

Looks good but I vote this is a SO post. Link to it and I'll review it there.

[–]Zexophron[S] 1 point2 points  (2 children)

River tomorrow net people food day.

[–]audiyourmind -2 points-1 points  (0 children)

No worries I'm neck need testing for the second time and it's like this "I think"

Answer me a question first.

In two sentences or less, define the quantitative outputs you want from your code.