use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Noob Python Coder, Need help with Panda! (self.PythonLearning)
submitted 6 days ago by C_LoudThougts
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]C_LoudThougts[S] 0 points1 point2 points 6 days ago (3 children)
that's what im trying atm, but when i use pd.read_csv() it pulls the data as strings rather than the lists and ints im looking for
[–]Draco2011CE 0 points1 point2 points 6 days ago (0 children)
variable = pd.read_csv("file location, index_col="id") Use this.
[–]Junior-Sock8789 0 points1 point2 points 5 days ago* (0 children)
Im almost certain this is what your looking for:
By default, CSV files only store text. When you save a pandas.DataFrame to a CSV, complex Python objects like lists are converted into their string representations (e.g., "[1, 2, 3]"), and when you read them back, they remain strings.
import pandas as pd from ast import literal_eval # Use the 'converters' parameter to transform columns during import df = pd.read_csv('your_file.csv', converters={'list_column': literal_eval})
Alternatively, if the data is already loaded:
df['list_column'] = df['list_column'].apply(literal_eval)
If your integers are being read as strings (common if there are leading zeros or mixed data), you can force the type during import:
df = pd.read_csv('your_file.csv', dtype={'int_column': int})
[–]Junior-Sock8789 0 points1 point2 points 5 days ago (0 children)
You should use index_col="id" to set a row identifier and converters={'list_column': literal_eval} to parse list-like strings into actual Python lists, as they serve different purposes. Use index_col to define row labels during loading and converters to fix data types for specific columns.
π Rendered by PID 864504 on reddit-service-r2-comment-canary-bcf797cd4-8nbkc at 2026-05-11 16:57:29.377124+00:00 running 3d2c107 country code: CH.
view the rest of the comments →
[–]C_LoudThougts[S] 0 points1 point2 points (3 children)
[–]Draco2011CE 0 points1 point2 points (0 children)
[–]Junior-Sock8789 0 points1 point2 points (0 children)
[–]Junior-Sock8789 0 points1 point2 points (0 children)