Python Forum
I need help with Python code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with Python code
#1
I have below array with 7R & 4C

Objective is to draw a pictorial graph capturing "how many Freq used/Free Freq in HOP A-B, B-C, C-D & A-D"
like manually i can judge from this small array that
Freq 1 occupied in all HOP A-B, B-C, C-D, A-D
Freq 2 occupied in B-C & C-D...free in A-B & A-D
Freq 3 occupied in A-B, B-C...free in C-D & A-D

Freq	HOP1	HOP2	HOP3
1	    A-B	    B-C	    NaN
1	    A-D		NaN     NaN
1	    C-D	    NaN     NaN
2	    B-C		NaN     NaN
2	    C-D		NaN     NaN
3	    A-B	    B-C	    NaN
I tried by using above data in CSV and loading in panda, as per online search tried seaborn but able to implement.
downloaded plotly as well, but iplot function not working.

import seaborn as sns
import numpy as np
import pandas as pd
import cufflinks as cf
import chart_studio.plotly as py
from chart_studio.plotly import plot, iplot
import chart_studio.tools as tls
import plotly.graph_objects as go
sns.set(style="whitegrid", color_codes=True)
df = pd.read_csv('C:\HardDisk\AMBER\All Docs\wave.csv')
print (df)
Reply
#2
The solution may depend upon the total number of observations and
if you mean "total freq" or "total DIFFERENT freq".
If there are many, and you need to count the different freq,
you might make a set() per frequency. freq1 = {A-B,...} etc.
The length of the set is the number you want. For the NaN, just count them while making the set.

This solution is based on assumptions, until we know exactly what you want to count.
Paul
It is more important to do the right thing, than to do the thing right.(P.Drucker)
Better is the enemy of good. (Montesquieu) = French version for 'kiss'.
Reply


Forum Jump:

User Panel Messages

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