Reputation: 55
I'm new to python and I'm looking to output to a pandas dataframe so that another package can pick it up.
Can somebody please explain what I need to do in practice?
For example, to output a table to a crosstab, I would do the following:
import pandas as pd
income_final =
pd.read_csv("D:\\data\\income17-18_data.csv")
income2 = income_final[(income_final.benefits == 1)]
pd.crosstab(income2.benefits, income2.taxes)
How would I go about outputting this into a pandas dataframe?
Much appreciated.
Upvotes: 0
Views: 55
Reputation: 86
As you can see on pandas documentation of read_csv the instruction:
pd.read_csv("D:\\data\\income17-18_data.csv")
returns a DataFrame, so you may store it on a variable to pass it as argument to other funcion or method:
dataFrame18 = pd.read_csv("D:\\data\\income17-18_data.csv")
So you can use dataFrame18. If you have doubts, check the type of a with:
type(dataFrame18)
After loading the data on a var.
Best regards, ealcober.
Upvotes: 1