Python Forum
change numerical values to categorical names
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
change numerical values to categorical names
#2
How can we help, if there is no code except the dictionary?
If you use pandas, you can do it easily, e.g.

In [75]: import pandas as pd
    ...:
    ...: mapper = {1: 'John', 2: 'July'}
    ...:
    ...: df = pd.DataFrame({'names': [1, 2, 1, 1], 'age': [10, 20, 10, 10]})
    ...:
    ...: df.names.map( mapper)
Output:
Out[75]: 0 John 1 July 2 John 3 John Name: names, dtype: object
Reply


Messages In This Thread
RE: change numerical values to categorical names - by scidam - Oct-25-2020, 11:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  output values change akbarza 3 1,559 Oct-18-2023, 12:30 PM
Last Post: deanhystad
  Print names in x-axis of a time-series values hobbyist 4 2,325 Apr-22-2023, 09:29 PM
Last Post: deanhystad
  restrict user input to numerical values MCL169 2 1,898 Apr-08-2023, 05:40 PM
Last Post: MCL169
Question Inserting Numerical Value to the Element in Optionlist and Printing it into Entry drbilgehanbakirhan 1 1,572 Jan-30-2023, 05:16 AM
Last Post: deanhystad
  Changing a string value to a numerical value using python code and a lamda function Led_Zeppelin 6 2,872 Jul-05-2022, 11:29 PM
Last Post: deanhystad
  Sorting numerical values provided by QAbstractTableModel BigMan 0 2,120 Jun-04-2022, 12:32 AM
Last Post: BigMan
  How to plot 3D graph of non numerical value? Gevni 0 2,742 Mar-05-2021, 02:50 PM
Last Post: Gevni
  Filtering Excel Document Data Based On Numerical Values eddywinch82 30 14,910 Feb-25-2020, 06:08 PM
Last Post: eddywinch82
  Using groupby on non-categorical values namy77 1 2,215 Feb-04-2020, 11:58 PM
Last Post: scidam
  'Age' categorical (years -months -days ) to numeric Smiling29 4 3,910 Oct-17-2019, 05:26 PM
Last Post: Smiling29

Forum Jump:

User Panel Messages

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