0

I will like to use pandas to summarize or visualize some useful summary from my data to highlight how suppliers deviate from the date order was due for supply. Here's a snippet of my data frame:

Supplier    TimeDiff (days)
A   3 days
B   4 days
B   12 days
A   0 days
C   1 days
B   2 days
D   3 days
E   5 days
E   7 days

"Supplier" column contain the supplier codes and "TimeDiff" column contain time difference (date range obtained by deducting "order due date" from "order received date").

Does anyone know how best I can summarise this data? Thanks

1
  • 2
    Can you be more specific? What do you want to learn from this data? You can for example get average "TimeDiff" for each supplier like this: data.groupby('Supplier').mean()['TimeDiff'] Commented Nov 1, 2016 at 22:48

1 Answer 1

2

I'd start with calculating the mean TimeDiff by supplier:

import matplotlib.pyplot as plt
import pandas as pd

df = pd.DataFrame([['A', '3 days'], ['B', '4 days'], ['B', '12 days'], ['A', '0 days']], columns=['Supplier', 'TimeDiff'])
df['TimeDiff'] = df['TimeDiff'].str.extract(r'(\d+)').astype(int)
print df.groupby('Supplier').mean()

          TimeDiff
Supplier          
A              1.5
B              8.0

res.plot.bar()
plt.show()

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you guys for these solutions. I wonder if its possible to compute a bar chart directly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.