0

Here's my file( edited with data included.)

import pandas as pd

df = pd.read_csv("test.csv")

print(df)

Here's the result. This dataframe comes up on Pycharm when I print it.

Date      Campaign
3/24/20   GA Shoes Search Campaign
3/24/20   GA Shoes Display Campaign
3/24/20   GA Bag Search Campaign
3/24/20   GA Bag Display Campaign
3/24/20   IG Shoes Campaign
3/24/20   IG Bag Campaign
3/24/20   FB Shoes Campaign
3/24/20   FB Bag Campaign
3/24/20   Email Campaign

But then when I created a function to edit my dataframe, it wouldn't come up anymore

def edit():
    new = df.loc[df.Campaign.str.startswith("GA")]
    return new
print(edit())

I want this to come up as a dataframe:

Date      Campaign
3/24/20   GA Shoes Search Campaign
3/24/20   GA Shoes Display Campaign
3/24/20   GA Bag Search Campaign
3/24/20   GA Bag Display Campaign

I tried debugger but only the original df comes up with "View as DataFrame," my new and edited dataframe won't show up. How do i make my edited dataframe show on Pycharm?

ssmm
  • 149
  • 2
  • 15
  • `.str` is method you can use only on `pd.series`. What do you want to do exactly ? Show us a sample of your df and the result you expect – Pi-R Aug 23 '20 at 08:08
  • @Pi-R it returned a series with boolean type. The result i want is the edited dataframe – ssmm Aug 23 '20 at 08:10
  • share the data so we can reproduce the problem. – Maxim Kogan Aug 23 '20 at 08:12
  • @MaximKogan post edited – ssmm Aug 23 '20 at 08:19
  • In Jupyter Notebook your code works fine. – Pi-R Aug 23 '20 at 08:32
  • @Pi-R I'm using Pycharm. I want the edited dataframe to show for me to check whether the result the code produced is what I really want. But in Pycharm the edited dataframe won't come up – ssmm Aug 23 '20 at 08:36
  • 1
    check this post https://stackoverflow.com/questions/23941580/is-there-a-variable-explorer-for-pycharm#:~:text=Click%20the%20debug%20button%20or,view%20it%20as%20a%20dataframe. – Pi-R Aug 23 '20 at 08:56

0 Answers0