2

I have a csv file with name "file.csv"

,DATE,DAY,OPEN,2PM,CLOSE,STATUS
0,2021-05-18,Tuesday,538.8,530.45,530.8,0
1,2021-05-19,Wednesday,530.65,532.6,536.85,0
2,2021-05-20,Thursday,536.95,537.05,536.35,1
3,2021-05-21,Friday,538.0,538.2,537.55,1
4,2021-05-24,Monday,537.3,535.05,532.85,1
5,2021-05-25,Tuesday,535.9,531.35,529.65,1
6,2021-05-26,Wednesday,532.95,530.55,532.1,0
7,2021-05-27,Thursday,532.95,529.65,529.85,0

I am using pandas to convert it to df.

import pandas as pd
df = pd.read_csv("file.csv")

df output can be seen as

enter image description here

There is a "STATUS" column that has 1 and 0 values.

I want to plot Monday to Friday from DAY column on the graph with values of STATUS column (i.e. 0 or 1). I want to see how many percentages of 0 or 1 were present on each days.

I do not know how to use these 2 columns for plotting such a graph.

Any help is appreciated.

6
  • 1
    What exactly do you want to plot Commented Jul 6, 2021 at 4:07
  • What do you mean "probability of 1/0 status mentioned on the graph"? The goal of the plot is unclear what information are you trying to visualize? Commented Jul 6, 2021 at 4:10
  • @Hemesh: Status column has 0 and 1 values. I want to plot them for days columns Commented Jul 6, 2021 at 4:10
  • @Henry Ecker: I want to plot pie chart or any graph wich can show different relationships of days column and status column Commented Jul 6, 2021 at 4:13
  • That's a super broad question. There are many visualizations that can show a relationship between two columns. What kind of pie chart? One for 0s and one for 1s?? Again, what information are you trying to visualize? What do you want the plot to demonstrate? Commented Jul 6, 2021 at 4:17

1 Answer 1

2

IIUC, do you want something like this:

df.groupby('DAY')['STATUS'].value_counts(normalize=True).unstack().plot.bar()

Output:

enter image description here

Pie chart:

df.groupby('DAY')['STATUS'].value_counts(normalize=True).unstack(0).plot.pie(subplots=True, figsize=(15,8))

Output:

enter image description here

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

5 Comments

if OP wants to reorder the days, add something like .reindex(['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'])
can we plot pie chat with DAYS, and STATUS?
Pie chart generally track one metric. 5 pie charts by day with status?
@Scott Boston: aaha and how to keep csv file name in the plot?
Add an annotation to the plot.

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.