Python Forum
Select specific index for plot
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Select specific index for plot
#1
Hey guys,

I do have here an issue, which I cannot solve alone and thus need your help.

I do have a very large csv table with 27 columns. What I did was to use the multiindex command for "date" and "time", since I do have an object which is observed for several months for a time frame, so you can imagine

Index 1-----Index 2----Attribute

1.1.2018---- 12:00-----0.1
-------------12:01-----0.004
-------------12:03------10



1.2.2018-----13:00-----0.234
-------------13:02-----0.432
-------------13:03-----0.12



.
.
.
.
12.12.2018---11:00-----0.342
-------------11:02-----0.123
-------------11:00-----0.12


So I hope yo guys can imagine the table. So what I did to get a plot was
Data_plot["Attribute"].plot()
If I execute this command I do get the right plot, however the x-axis has the label "Date" and "time", so the multiindex items.

Question: How can I show on the x-axis the date and not the time??

I would be happy for any kind of help
Reply
#2
You probably need to get mean/median values of the attribute per day.

Try this:

your_df.groupby('date_index').mean()['Attribute'].plot()
Also, you can call more general (.transform) method instead of mean:

your_df.groupby('date_index').transform(pd.np.mean)['Attribute'].plot()
# or 
your_df.groupby('date_index').transform(lambda x: your_func(x))['Attribute'].plot()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [split] Getting Index Error - list index out of range krishna 2 2,568 Jan-09-2021, 08:29 AM
Last Post: buran
  Getting Index Error - list index out of range RahulSingh 2 6,102 Feb-03-2020, 07:17 AM
Last Post: RahulSingh
  Select in Multi Index Pandas diego_last 0 2,323 Aug-01-2018, 12:56 PM
Last Post: diego_last

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020