getting this on dataframe 'int' object has no attribute 'lower'

pandas groupby
pandas dataframe get cell value
pandas iloc
pandas loc
pandas series
pandas get index
pandas get row by index
pandas select columns
df23 = pd.DataFrame({'name':['MY NAME1', 'MY NAME2', 'MY NAME3','MY NAME4'],
                    'description': [['d1 d2 d3'], ['d4 d5 d6'], ['d7 d8 d9'],['a9 d0 t5']],
                   'specialties': ['green,red,blue', 'green,purple,pink', 'yellow,white,black,red,green', 'bub.tub,rub'],
                    })
df_work['name'] = [x for x in df_work['name'].map(lambda x: x.lower())]

I want to convert all entries in name col to lower. But i am getting this error.

If df_work is an existing dataframe then you may use:

df_work['name'] = df23['name'].apply(lambda x: x.lower())

else use:

df_work = pd.DataFrame(df23['name'].apply(lambda x: x.lower()), columns = ['name'])

Indexing and selecting data — pandas 1.1.0 documentation, Allows intuitive getting and setting of subsets of the data set. In this section, we will focus on the final point: namely, how to slice, dice, and generally get and set � pandas.DataFrame.get¶ DataFrame.get (key, default = None) [source] ¶ Get item from object for given key (ex: DataFrame column). Returns default value if not found. Parameters key object

It seems some value is integer, so is necessary converting to string:

df_work['name'] = [x for x in df_work['name'].map(lambda x: str(x).lower())]

Another solution with Series.astype and Series.str.lower:

df_work['name'] = df_work['name'].astype(str).str.lower()

10 minutes to pandas — pandas 1.1.0 documentation, we import as follows: In [1]: import numpy as np In [2]: import pandas as pd For getting fast access to a scalar (equivalent to the prior method):. In [31]:� pandas.DataFrame.info¶ DataFrame.info (verbose = None, buf = None, max_cols = None, memory_usage = None, null_counts = None) [source] ¶ Print a concise summary of a DataFrame. This method prints information about a DataFrame including the index dtype and columns, non-null values and memory usage.

Try this:

df23['name'] = df23['name'].astype('str').map(lambda x: x.lower())

pandas.DataFrame.values — pandas 1.1.0 documentation, DataFrame.get � pandas.DataFrame.isin � pandas.DataFrame.where � pandas. DataFrame.mask � pandas.DataFrame.query � pandas.DataFrame.add � pandas. df23 = pd.DataFrame({'name':['MY NAME1', 'MY NAME2', 'MY NAME3','MY NAME4'], 'description': [['d1 d2 d3'], ['d4 d5 d6'], ['d7 d8 d9'],['a9 d0 t5']], 'specialt

Python, Pandas dataframe.get() function is used to get item from object for given key. The key could be one or more than one dataframe column. Pandas dataframe.get () function is used to get item from object for given key. The key could be one or more than one dataframe column. It returns default value if not found. Syntax: DataFrame.get (key, default=None)

How to get column names in Pandas dataframe, Now let's try to get the columns name from above dataset. Method #1: Simply iterating over columns. Steps to Get the Descriptive Statistics for Pandas DataFrame Step 1: Collect the Data To start, you’ll need to collect the data for your DataFrame. For example, I collected the Step 2: Create the DataFrame Next, you’ll need to create the DataFrame based on the data collected. For our example,

How to get a value from a cell of a dataframe?, If you have a DataFrame with only one row, then access the first (only) row as a Series using iloc , and then the value using the column name: Pandas dataframe.get_value() function is used to quickly retrieve single value in the data frame at passed column and index. The input to the function is the row label and the column label. Syntax: DataFrame.get_value(index, col, takeable=False) Parameters : index : row label col : column label takeable : interpret the index/col as indexers

Comments
  • what is df_work ? Is this df23? If so it works well to me