I want to use Seaborn.lmplot for scattering Dataframe's "column 1" vs "column 2" , but in according to Seaborn documentation :
Seaborn.lmplot(x, y, data, hue=None, ...)
We should provide names of columns for using this function, in other words Dataframes columns should be strings instead of integers.
I've tried a following methods, but none of them works!
import seaborn as sns
import pandas as pd
df = pd.read_csv('someData.csv',sep=',', header=None)
sns.lmplot(0,1, data= df)
sns.lmplot(df[0], df[1])
sns.lmplot("0","1",data= df)
and my dataFrame is something like:
Is there any method that I can use Seaborn.lmplot without naming columns!
lmplot() method is used to draw a scatter plot onto a FacetGrid.
Selecting columns based on their name This is the most basic way to select a single column from a dataframe, just put the string name of the column in brackets. Returns a pandas series. Passing a list in the brackets lets you select multiple columns at the same time.
The lineplot (lmplot) is one of the most basic plots. It shows a line on a 2 dimensional plane. You can plot it with seaborn or matlotlib depending on your preference.
Seaborn does not allows for unnamed columns.
However, an easy solution is to rename the columns just for the purpose of plotting. Mapping the integer to a string (lambda x: str(x)
) would allow to use strings as column names for the seaborn plot.
sns.lmplot(x="0", y="1", data=df.rename(columns=lambda x: str(x)))
The original dataframe will stay unchanged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With