Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Variable contents
#1
I mainly use SAS and it has a procedure called proc freq which lists the contents of a variable and how frequently it is populated. Does python have anything similar?

Thanks
Reply
#2
It can't - variable in Python is just a placeholder for object reference, and it - the variable - may be re-assigned with reference to another object, or be deleted.
Test everything in a Python shell (iPython, Azure Notebook, etc.)
  • Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
  • Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
  • You posted a claim that something you did not test works? Be prepared to eat your hat.
Reply
#3
See collections.Counter.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
(Jun-21-2018, 07:22 AM)Scott Wrote: I mainly use SAS and it has a procedure called proc freq which lists the contents of a variable and how frequently it is populated. Does python have anything similar?
Variable may not the right word to use if talking about Python,value in a dataset may fit better.
SAS Wrote:Proc FREQ is a procedure that is used to give descriptive statistics about a particular data set.
Proc FREQ is widely used to analyze healthcare datasets and
demographic databanks that contain specific information about individuals and their activities
So with this info about what proc freq dos,then will Pandas fit this description right on.
Pandas is used for this a lot,eg load a datasets and doing stuff like frequency count.
# SAS 
proc freq data=mydata;
    tables myvar / nocol nopercent nocum;
run;

# Pandas
mydata.myvar.value_counts().sort_index()
Reply


Forum Jump:

User Panel Messages

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