The simplest way is just to not input any filename, in this case a string is returned:
>>> df = pd.DataFrame({'A' : [0, 1], 'B' : [1, 6]})
>>> df.to_csv()
',A,B\n0,0,1\n1,1,6\n'
More Related Contents:
- Pandas conditional creation of a series/dataframe column
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- How to unnest (explode) a column in a pandas DataFrame, into multiple rows
- Get the row(s) which have the max value in groups using groupby
- Why does concatenation of DataFrames get exponentially slower?
- Remove unwanted parts from strings in a column
- Combine Date and Time columns using python pandas
- Accessing Pandas column using squared brackets vs using a dot (like an attribute)
- Pandas Timedelta in Days
- how to get ticks every hour?
- How to add value labels on a bar chart
- How to remove blanks/NA’s from dataframe and shift the values up
- Why does my Pandas DataFrame not display new order using `sort_values`?
- python/pandas: convert month int to month name
- How to check if a column exists in Pandas
- Difference(s) between merge() and concat() in pandas
- Seaborn showing scientific notation in heatmap for 3-digit numbers
- Format certain floating dataframe columns into percentage in pandas
- How can I see the formulas of an excel spreadsheet in pandas / python?
- Count distinct words from a Pandas Data Frame
- How to annotate each segment of a stacked bar chart
- python pandas groupby() result
- How to implode(reverse of pandas explode) based on a column
- Pandas concat yields ValueError: Plan shapes are not aligned
- how to replace an entire column on Pandas.DataFrame
- Creating dummy variables in pandas for python
- How to convert DataFrame.append() to pandas.concat()?
- how to save a pandas DataFrame to an excel file?
- How to efficiently assign unique ID to individuals with multiple entries based on name in very large df
- Add image annotations to bar plots