lux-org / lux

Automatically visualize your pandas dataframe via a single print! 📊 💡
Apache License 2.0
5.15k stars 365 forks source link

How do you export the underlying means data from the chart vislist? #383

Closed Josephsmurph13 closed 3 years ago

Josephsmurph13 commented 3 years ago

from lux.vis.VisList import VisList vc = VisList(["Target","?"],df) vc

print(VisList(["Target","?"],df))

When you print it just gives you the target variable and the other feature variable. I am looking to extract the mean of the target for the various categorial values within this feature variable?

I have tried print (vc.to_matplotlib()) but this doesn't appear to work.

Any help would be much appreciated.

Kind regards Joe

dorisjlee commented 3 years ago

Hi @Josephsmurph13, Thanks for your question! I'm glad that you are finding the VisList useful, it is a very convenient way to work with lots of visualizations at once!

When you are working with the VisList, it is a list of visualization, if you are interested in fetching the data values (e.g. mean expressed by the bar chart), or converting it into matplotlib, you would need to access the Vis element in your VisList, like barchart = vc[1] for the second Vis in your VisList.

df = pd.read_csv("https://github.com/lux-org/lux-datasets/blob/master/data/hpi_full.csv?raw=True")
from lux.vis.VisList import VisList
vc = VisList(["AvrgLifeExpectancy","?"], df)
barchart = vc[1]

Screen Shot 2021-06-17 at 7 18 58 PM

To fetch the data itself, you can use the .data property. You can also call .to_matplotlib() on the Vis to get the matplotlib code.

barchart.data

print(barchart.to_matplotlib())

Let me know if that answers your question!

Josephsmurph13 commented 3 years ago

Hi @Doris @.***>,

Thank you very much for you quick response. The instructions below do exactly what I want. I see, you have to extract each charts data individually and not in a list (VisList).

I am very new to Python and am really impressed with Lux as a means of quickly visualising data relationships.

Kind regards, Joe

Joseph Murphy Senior Consultant Direct : +44 113 306 1594 | Mobile : +44 7733 013 876 | @.**@.>

[test]http://www.gmap.com/ GMAP Analytics Ltd | www.gmap.comhttp://www.gmap.com/ | GMAP Analytics, Nexus - University of Leeds, Discovery Way, Leeds, LS2 3AA, United Kingdom [LI-In-Bug] http://www.linkedin.com/company/gmap-analytics

From: Doris Lee @.> Sent: 18 June 2021 03:23 To: lux-org/lux @.> Cc: Joseph Murphy @.>; Mention @.> Subject: Re: [lux-org/lux] How do you export the underlying means data from the chart vislist? (#383)

Hi @Josephsmurph13https://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FJosephsmurph13&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539751879%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=L%2FhkeWMmYVdJXuasVGUaTCWwZCX5iho8hwNxMTnLN18%3D&reserved=0, Thanks for your question! I'm glad that you are finding the VisList useful, it is a very convenient way to work with lots of visualizations at once!

When you are working with the VisList, it is a list of visualization, if you are interested in fetching the data values (e.g. mean expressed by the bar chart), or converting it into matplotlib, you would need to access the Vis element in your VisList, like barchart = vc[1] for the second Vis in your VisList.

df = pd.read_csv("https://github.com/lux-org/lux-datasets/blob/master/data/hpi_full.csv?raw=True")

from lux.vis.VisList import VisList

vc = VisList(["AvrgLifeExpectancy","?"], df)

barchart = vc[1]

[Screen Shot 2021-06-17 at 7 18 58 PM]https://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F5554675%2F122496588-e0e8c400-cfa0-11eb-9f1b-f4a49e46edef.png&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539761836%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=S%2BAzAQB8aCLLwgLHR6ka4GUlrMwPkxa8JMsGj6B7KUk%3D&reserved=0

To fetch the data itself, you can use the .data property. You can also call .to_matplotlib() on the Vis to get the matplotlib code.

barchart.data

print(barchart.to_matplotlib())

[https://user-images.githubusercontent.com/5554675/122496654-f958de80-cfa0-11eb-9d4a-ada7a9fd4671.png]https://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F5554675%2F122496654-f958de80-cfa0-11eb-9d4a-ada7a9fd4671.png&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539761836%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=6N232HUawS5StfaWkePvOv5AcCkfK2dDHCJxgOIPZoE%3D&reserved=0

Let me know if that answers your question!

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flux-org%2Flux%2Fissues%2F383%23issuecomment-863705826&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539771790%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2F2jxagA6%2Fa4wcm%2FDRBzkezbcW5lv8wH7ZWJJvEYvHy8%3D&reserved=0, or unsubscribehttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAUPGGCVMCPT3FJE7RK2NXBLTTKUWPANCNFSM463JFTBA&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539771790%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=6W6X5GNuR1AmpGJ3gJUkJ%2BUI3TTsmzY1Hcwyhb9GY9I%3D&reserved=0.

dorisjlee commented 3 years ago

Hi @Josephsmurph13, Glad to hear that you're finding Lux useful! Feel free to let us know if you run into any other questions!

Josephsmurph13 commented 3 years ago

Hi,

I have got a new laptop and am trying to toggle to lux from panda but can't get the charts to show

@.***

I have run the below so far. Please could you kindly advise how I get the charts to show? Lux is a great tool but just can't get it to work atm?

pip uninstall lux-api

pip uninstall lux-widget

jupyter nbextension uninstall --py luxWidget

jupyter nbextension disable --py luxWidget

pip install lux-api

jupyter nbextension install --py luxwidget

jupyter nbextension enable --py luxwidget

jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter labextension install jupyter-matplotlib

Kind regards, Joe

Joseph Murphy Senior Consultant @.**@.>

[test]http://www.gmap.com/ GMAP Analytics Ltd | www.gmap.comhttp://www.gmap.com | | GMAP Analytics, Nexus - University of Leeds, Discovery Way, Leeds, LS2 3AA, United Kingdom [LI-In-Bug] http://www.linkedin.com/company/gmap-analytics

From: Joseph Murphy Sent: 18 June 2021 09:50 To: lux-org/lux @.>; lux-org/lux @.>; Doris Lee @.> Cc: Mention @.> Subject: RE: [lux-org/lux] How do you export the underlying means data from the chart vislist? (#383)

Hi @Doris @.***>,

Thank you very much for you quick response. The instructions below do exactly what I want. I see, you have to extract each charts data individually and not in a list (VisList).

I am very new to Python and am really impressed with Lux as a means of quickly visualising data relationships.

Kind regards, Joe

Joseph Murphy Senior Consultant Direct : +44 113 306 1594 | Mobile : +44 7733 013 876 | @.**@.>

[test]http://www.gmap.com/ GMAP Analytics Ltd | www.gmap.comhttp://www.gmap.com/ | GMAP Analytics, Nexus - University of Leeds, Discovery Way, Leeds, LS2 3AA, United Kingdom [LI-In-Bug] http://www.linkedin.com/company/gmap-analytics

From: Doris Lee @.**@.>> Sent: 18 June 2021 03:23 To: lux-org/lux @.**@.>> Cc: Joseph Murphy @.**@.>>; Mention @.**@.>> Subject: Re: [lux-org/lux] How do you export the underlying means data from the chart vislist? (#383)

Hi @Josephsmurph13https://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FJosephsmurph13&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539751879%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=L%2FhkeWMmYVdJXuasVGUaTCWwZCX5iho8hwNxMTnLN18%3D&reserved=0, Thanks for your question! I'm glad that you are finding the VisList useful, it is a very convenient way to work with lots of visualizations at once!

When you are working with the VisList, it is a list of visualization, if you are interested in fetching the data values (e.g. mean expressed by the bar chart), or converting it into matplotlib, you would need to access the Vis element in your VisList, like barchart = vc[1] for the second Vis in your VisList.

df = pd.read_csv("https://github.com/lux-org/lux-datasets/blob/master/data/hpi_full.csv?raw=True")

from lux.vis.VisList import VisList

vc = VisList(["AvrgLifeExpectancy","?"], df)

barchart = vc[1]

[Screen Shot 2021-06-17 at 7 18 58 PM]https://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F5554675%2F122496588-e0e8c400-cfa0-11eb-9f1b-f4a49e46edef.png&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539761836%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=S%2BAzAQB8aCLLwgLHR6ka4GUlrMwPkxa8JMsGj6B7KUk%3D&reserved=0

To fetch the data itself, you can use the .data property. You can also call .to_matplotlib() on the Vis to get the matplotlib code.

barchart.data

print(barchart.to_matplotlib())

[https://user-images.githubusercontent.com/5554675/122496654-f958de80-cfa0-11eb-9d4a-ada7a9fd4671.png]https://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F5554675%2F122496654-f958de80-cfa0-11eb-9d4a-ada7a9fd4671.png&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539761836%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=6N232HUawS5StfaWkePvOv5AcCkfK2dDHCJxgOIPZoE%3D&reserved=0

Let me know if that answers your question!

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flux-org%2Flux%2Fissues%2F383%23issuecomment-863705826&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539771790%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=%2F2jxagA6%2Fa4wcm%2FDRBzkezbcW5lv8wH7ZWJJvEYvHy8%3D&reserved=0, or unsubscribehttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAUPGGCVMCPT3FJE7RK2NXBLTTKUWPANCNFSM463JFTBA&data=04%7C01%7Cjoseph.murphy%40gmap.com%7Ca66bebc1b1014056295108d931ffed92%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637595797539771790%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=6W6X5GNuR1AmpGJ3gJUkJ%2BUI3TTsmzY1Hcwyhb9GY9I%3D&reserved=0.

dorisjlee commented 3 years ago

Hi @Josephsmurph13, Could you open a new issue describing the problem that you're seeing? It would also be great to describe whether you are using Jupyter Notebook or Jupyter Lab, as well as what error message or screenshot of display you are seeing after you run the following example in your notebook:

import lux
import pandas as pd
df = pd.read_csv("https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/college.csv")
df

Thanks again and we're excited to hear that you're continuing to use Lux!

Josephsmurph13 commented 3 years ago

Hi Doris,

I have sorted the issue by uninstalling Lux and jupyter lab. This appears to have fixed it. Thanks for getting back to me so quickly.

Kind regards, Joe

Joseph Murphy Senior Consultant @.**@.>

[test]http://www.gmap.com/ GMAP Analytics Ltd | www.gmap.comhttp://www.gmap.com | | GMAP Analytics, Nexus - University of Leeds, Discovery Way, Leeds, LS2 3AA, United Kingdom [LI-In-Bug] http://www.linkedin.com/company/gmap-analytics

From: Doris Lee @.> Sent: 17 September 2021 06:49 To: lux-org/lux @.> Cc: Joseph Murphy @.>; Mention @.> Subject: Re: [lux-org/lux] How do you export the underlying means data from the chart vislist? (#383)

Hi @Josephsmurph13https://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FJosephsmurph13&data=04%7C01%7Cjoseph.murphy%40gmap.com%7C8a33331450d84ae6dcb408d9799ee2b0%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637674545580735956%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=2xdkB5Chi0iFyaSwpooOMIHlyni08vRXvOeTXK6guhw%3D&reserved=0, Could you open a new issuehttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flux-org%2Flux%2Fissues%2Fnew%2Fchoose&data=04%7C01%7Cjoseph.murphy%40gmap.com%7C8a33331450d84ae6dcb408d9799ee2b0%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637674545580735956%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=rZKu6n6dt1vAYkn56kEKkH9PHSgoFecJELc%2Fl21Xbbg%3D&reserved=0 describing the problem that you're seeing? It would also be great to describe whether you are using Jupyter Notebook or Jupyter Lab, as well as what error message or screenshot of display you are seeing after you run the following example in your notebook:

import lux

import pandas as pd

df = pd.read_csv("https://raw.githubusercontent.com/lux-org/lux-datasets/master/data/college.csv")

df

Thanks again and we're excited to hear that you're continuing to use Lux!

- You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Flux-org%2Flux%2Fissues%2F383%23issuecomment-921517584&data=04%7C01%7Cjoseph.murphy%40gmap.com%7C8a33331450d84ae6dcb408d9799ee2b0%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637674545580745917%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=qd1EqarXC6KOgh1Ofm4yBWlqMXSMbaWECFvd0HLGjZI%3D&reserved=0, or unsubscribehttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAUPGGCRXRDVRIGL4USV5RADUCLJFXANCNFSM463JFTBA&data=04%7C01%7Cjoseph.murphy%40gmap.com%7C8a33331450d84ae6dcb408d9799ee2b0%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637674545580745917%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=BsHEB8WfYniSGLx0Qe9tBRVgQVYv3ZdHGYox7Agzt04%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Cjoseph.murphy%40gmap.com%7C8a33331450d84ae6dcb408d9799ee2b0%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637674545580755874%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Aih0i9prsoY5YNY8Kjbcx56SchMRqzea3K8iFHSjoZA%3D&reserved=0 or Androidhttps://gbr01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Cjoseph.murphy%40gmap.com%7C8a33331450d84ae6dcb408d9799ee2b0%7Cc3dbf3eec71c421c833ebb6f597dadba%7C0%7C0%7C637674545580755874%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=QB7VsxGNYzS3u%2FNtFQno3jYNFZdY0V%2FYyU3KlfIh06I%3D&reserved=0.