One way to convert to string is to use astype:

total_rows['ColumnID'] = total_rows['ColumnID'].astype(str)

However, perhaps you are looking for the to_json function, which will convert keys to valid json (and therefore your keys to strings):

In [11]: df = pd.DataFrame([['A', 2], ['A', 4], ['B', 6]])

In [12]: df.to_json()
Out[12]: '{"0":{"0":"A","1":"A","2":"B"},"1":{"0":2,"1":4,"2":6}}'

In [13]: df[0].to_json()
Out[13]: '{"0":"A","1":"A","2":"B"}'

Note: you can pass in a buffer/file to save this to, along with some other options...

Answer from Andy Hayden on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.to_string.html
pandas.DataFrame.to_string — pandas 3.0.6 documentation
Formatter function to apply to columns’ elements if they are floats. This function must return a unicode string and will be applied only to the non-NaN elements, with NaN being handled by na_rep.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › pandas-convert-column-to-string-type
Pandas Convert Column To String Type - GeeksforGeeks
July 23, 2025 - The astype() method in Pandas is a straightforward way to change the data type of a column to any desired type. The astype method has the following syntax: ... Here we define that the numeric type for the dataset should be converted to a string ...
Discussions

python - Convert columns to string in Pandas - Stack Overflow
I have the following DataFrame from a SQL query: (Pdb) pp total_rows ColumnID RespondentCount 0 -1 2 1 3030096843 1 2 3030096845 1 and I More on stackoverflow.com
🌐 stackoverflow.com
Pandas: converting entire dataframe to string type, except for NaN entries
Can't u delete every NaN with regex from your text ? Excuse me if i'm suggesting something irrelevant kinda new to programming More on reddit.com
🌐 r/learnpython
7
1
January 29, 2021
pandas dataframe - ValueError: could not convert string to float: 'None'

When debugging stuff like this, it helps to find a specific example where that triggers the error. Assuming your data has 100 rows, proceed as follows..

  1. Does the error occur on the first element? df.iloc[0].pct_used.astype(float)

  2. Does the error occur in the first half of the data? df.iloc[:50].pct_used.astype(float)

    1. If yes, does the error occur in the first quarter of the data? df.iloc[:25].pct_used.astype(float)

    2. If no, does the error occur in the second quarter of the data? df.iloc[74:].pct_used.astype(float)

... continue until you find a specific example that triggers the error.

A possibly quicker technique would be to sort the data alphabetically and give it the ole eyeball inspection. df.pct_used.unique().sort_vaues()

More on reddit.com
🌐 r/learnpython
5
1
July 18, 2021
pandas: convert strings to boolean columns
I'm not a pandas guy, so there's probably a better way, but a simple loop and check seems to work: tags = (tag for tags in df.tags for tag in tags.split(',')) for tag in set(tags): df[tag] = df.tags.str.contains(tag) More on reddit.com
🌐 r/learnpython
3
2
December 4, 2020
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › how-to-convert-pandas-columns-to-string
How to Convert Pandas Columns to String - GeeksforGeeks
July 23, 2025 - This method successfully converts the Numeric_Column from an integer type to a string. The map() function in Pandas is used for element-wise transformations.
🌐
Vultr Docs
docs.vultr.com › python › third party › pandas › dataframe › to_string()
Python Pandas DataFrame to_string() - Convert to String ...
December 30, 2024 - Begin with a basic example of converting a complete DataFrame to a string. ... import pandas as pd data = {'Name': ['Alice', 'Bob', 'Charlie'], 'Age': [25, 30, 35]} df = pd.DataFrame(data) print(df.to_string())
🌐
Medium
medium.com › @whyamit404 › steps-to-pandas-convert-column-to-string-6154c98e3ae5
Steps to Pandas Convert Column to String | by whyamit404 | Medium
April 12, 2025 - Type checking: After converting a column, you may want to check if the operation worked successfully. Use the dtypes attribute for this: ... You’ll see that the type for ‘Scores’ is now object, which is the generic type for strings in Pandas.
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas convert column to string type
Pandas Convert Column to String Type - Spark By {Examples}
July 3, 2025 - In this article, I will explain how to convert single column or multiple columns to string type in pandas DataFrame, here, I will demonstrate using
Find elsewhere
🌐
datagy
datagy.io › home › pandas tutorials › pandas dataframes › pandas: convert column values to strings
Pandas: Convert Column Values to Strings • datagy
December 15, 2022 - Doing this will ensure that you are using the string datatype, rather than the object datatype. This will ensure significant improvements in the future. Let’s take a look at how we can convert a Pandas column to strings, using the .astype() method:
🌐
Programiz
programiz.com › python-programming › pandas › methods › to_string
Pandas to_string()
The to_string() method in Pandas is used to convert a DataFrame or Series into a string representation
🌐
Medium
medium.com › @machinelearningpy123 › pandas-dataframe-to-string-conversion-7-code-examples-c6a9c2f50c53
Pandas DataFrame to String Conversion [7 Code Examples] | by Zeeshan Ali | Medium
November 19, 2023 - A DataFrame in Pandas is a two-dimensional labeled data structure with columns that can be of different data types. Converting it to a string means representing the DataFrame as a textual format, which can then be stored or manipulated easily.
🌐
Scaler
scaler.com › home › topics › pandas › convert column to string in pandas
Convert Column to String in Pandas - Scaler Topics
December 19, 2022 - When we wish to convert a certain column data type to another data type, the DataFrame.astype() method is really helpful. Additionally, we may alter many column types at once by using a Python dictionary input. The dictionary's key label corresponds to the name of the column, and the values label to the new data types we want the columns to contain. ... Pandas string operations are not restricted to what we have described here, but the functions and techniques we reviewed will undoubtedly aid in the processing of string data and speed up the data cleaning and preparation process.
🌐
Statology
statology.org › home › how to convert pandas dataframe columns to strings
How to Convert Pandas DataFrame Columns to Strings
July 29, 2020 - We can convert the column “points” to a string by simply using astype(str) as follows:
🌐
Seaborn Line Plots
marsja.se › home › programming › pandas convert all columns to string: a comprehensive guide
Pandas Convert All Columns to String: A Comprehensive Guide
September 17, 2025 - How to Convert a Float Array to an Integer Array in Python with NumPy · In Pandas programming, the .to_string() function emerges as a concise yet potent tool for transforming an entire dataframe into a string representation.
🌐
IncludeHelp
includehelp.com › python › how-to-convert-column-value-to-string-in-pandas-dataframe.aspx
How to convert column value to string in pandas DataFrame?
# Importing Pandas package import pandas as pd # Create a dictionary d = { 'One':[1,2,3,4], 'Two':['One','Two','Three','Four'] } # Create DataFrame df = pd.DataFrame(d) # Display DataFrame print("Created DataFrame:\n",df) # Display df.info print("Original Data Type:\n",df.info()) # Converting column One values into string type df['One'] = df['One'].astype('string') # Display df.info print("New Data Type:\n",df.info()) ... How to select rows with one or more nulls from a Pandas DataFrame without listing columns explicitly?
🌐
GITNUX
blog.gitnux.com › home › programming-advice
How can I convert a column in a Pandas DataFrame to a string in Python? • Gitnux
October 5, 2023 - You can convert a column in a Pandas DataFrame to a string using the `astype()` method.
🌐
Appdividend
appdividend.com › converting-columns-to-string-in-pandas-dataframe
Converting Columns to String in Pandas DataFrame
January 7, 2025 - You can convert any columns of a DataFrame to string in Pandas using the “astype()” or “apply()” function.